You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark.
GRMustache does no longer raise an exception when a template can't evaluate a filter expression such as {{ f(x) }}
.
Instead, an error is returned, with new GRMustache error code GRMustacheErrorCodeRenderingError
.
Text templates
Text templates render text, and do not HTML-escape their input.
Check the HTML vs. Text Templates Guide.
Garbage collection support.
The parser now rejects expressions identifiers that start with a reserved Mustache character: {}<>&#^$/
(those are the characters that start Mustache tags).
This will help the most daring of you who try to push Mustache off limits:
{{ >foo }}
looks a lot like a partial tag, but is not. It will now yield a parse error (because>foo
turns out to be an invalid expression for a variable tag).{{{#foo}}}...{{{/foo}}}
looks a lot like an "unescaped section tag", but there is no such tag in Mustache. This string will now yield a parse error (because#foo
and/foo
turn out to be invalid expressions for triple-mustache unescaped variable tags).
Improved template debugging: errors are logged when you do not handle them.
You don't have to close a regular section if it is immediately followed by its inverted form: {{#name}}...{{^name}}...{{/name}}
The short form {{#name}}...{{^}}...{{/}}
is accepted, as well as the "unless" form {{^name}}...{{#}}...{{/}}
.
Robustness of protected contexts. Check the "Protected namespaces" section of the Protected Contexts Guide.
GRMustache has recently been suffering of overengineering and API bloat. GRMustache 6 drastically reduces the surface of the interface.
Removed APIs:
-
GRMustacheDynamicPartial
,GRMustacheProxy
,GRMustacheSectionTagHelper
,GRMustacheVariableTagHelper
, and their companion classes have all been gathered in theGRMustacheRendering
protocol, covered in the Rendering Objects Guide. -
GRMustacheInvocation
andGRMustacheTemplateDelegate
have been replaced byGRMustacheTagDelegate
, covered in the Tag Delegates Guide. -
The
GRMustacheTemplate
andGRMustacheTemplateRepository
classes have lost many methods that used to cripple the autocompletion menu of Xcode. All removed shortcut are still eventually available through template repositories.
New rendering engine behavior:
-
The sections of overridable partials behave more like Ruby on Rails'
<% content_for(:foo) do %>...<% end %>
: multiple overriding sections are now concatenated, when GRMustache 5 used to render the last one only. See the Partials Guide. -
Filters are no longer provided in a separate container (the
renderObject:withFilters:
method is removed). All objects that enter the context stack can now provide filters (and supersede filters defined in parent contexts). You may want to check the Protected Contexts Guide if you want to protect your filter keys.
Bug fixes
Variadic filters can now return filters, just as filters with a single argument.
Niceties and bug fixes
The count
method of NSArray, NSSet and NSOrderedSet can now be queried in templates: {{collection.count}}
renders as expected, and {{#collection.count}}...{{/}}
can conditionally render a section if and only if the collection is not empty. See Guides/runtime/context_stack.md for a detailed explanation.
Variadic filters that return nil used to not play well with boolean sections.
GRMustacheProxy cooperates with NSUndefinedKeyException
prevention, and keeps its delegate quiet after you have invoked [GRMustache preventNSUndefinedKeyExceptionAttack]
.
GRMustacheProxy refuses nil
delegate, since it can not pose as nil
. You must use [NSNull null] instead.
Filters can now take several arguments: {{ f(a,b) }}
. Check Guides/filters.md.
Proxies are a tool for the developer who wants to write reusable and robust filters, helpers, and template delegates that extend the abilities of the rendered data. Check Guides/proxies.md.
The array indexes.md sample code now uses proxies. The visible benefit is that the sample code is shorter. It is also more robust. Before proxies were introduced, we used not to be able to properly render indexes for "special" array items such as NSNull, false booleans, or helpers. Proxies are really all about robustness.
- Fix a memory leak in overridable partials.
- Until this version, GRMustache would not trigger delegate methods for objects conforming to both GRMustacheVariableHelper and GRMustacheTemplateDelegate protocols.
Until this version, GRMustache would not trigger section tag helpers, variable tag helpers and tag delegates in a few corner cases.
Until this version, filters could not return filters. This useless inconsistency is considered a bug, and has been fixed. Check Guides/filters.md.
Fix some corner cases in the handling of overridable partials, should your templates include conflicting overriding sections. Basically, the last one wins:
{{<layout}} {{$content}}Not rendered{{/content}} {{$content}}Rendered{{/content}} {{/layout}}
.
When your templates are stored in a hierarchy of directories, you need to refer to partial templates in both relative and absolute ways, depending on the context.
Your variable tag helpers and your section tag helpers will typically use absolute paths, in order to always include the same partial template, regardless of the hierarchical position of the templates that use them.
Relative partial paths look like regular Mustache partial tags: {{> header }}
, {{> partials/header }}
.
GRMustache v5.4.0 brings absolute paths, that start with a slash: {{> /partials/header }}
.
The full story starts at Guides/partials.md.
The introduction of variable tag helpers in v5.1.0 introduced many confusing APIs. Those are still there, but deprecated.
No new feature has been added, but semantics have been much improved. Many thanks to @pierlo for his help.
Helpers API changes
GRMustacheVariableTagHelper
replaces GRMustacheVariableHelper
. See Guides/variable_tag_helpers.md.
@protocol GRMustacheVariableTagHelper<NSObject>
@required
- (NSString *)renderForVariableTagInContext:(GRMustacheVariableTagRenderingContext *)context;
@end
@interface GRMustacheVariableTagRenderingContext : NSObject
- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
- (NSString *)renderTemplateNamed:(NSString *)name error:(NSError **)outError;
@end
GRMustacheSectionTagHelper
replaces GRMustacheSectionHelper
. See Guides/section_tag_helpers.md.
@protocol GRMustacheSectionTagHelper<NSObject>
@required
- (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context;
@end
@interface GRMustacheSectionTagRenderingContext: NSObject
@property (nonatomic, readonly) NSString *innerTemplateString;
- (NSString *)render;
- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
@end
GRMustacheTemplateDelegate API changes
In the GRMustacheInterpretation
enumeration, GRMustacheSectionTagInterpretation
replaces GRMustacheInterpretationSection
, and GRMustacheVariableTagInterpretation
replaces GRMustacheInterpretationVariable
.
GRMustacheTemplate API changes
[GRMustacheTemplate renderObjectsFromArray:]
and [GRMustacheTemplate renderObjectsFromArray:withFilters:]
replace [GRMustacheTemplate renderObjectsInArray:]
and [GRMustacheTemplate renderObjectsInArray:withFilters:]
.
Overridable partials
Inspired by hogan.js and spullara/mustache.java, GRMustache now supports "template inheritance". Precisely, your templates can embed as many partials as before, but now you can override portions of those partials.
Overridable partials are documented as Guides/partials.md.
The layout sample code has been updated to take profit of overridable partials. There is not much left of it :-).
libGRMustache5-iOS.a is now compiled with Xcode 4.5, and does not longer embed the armv6 slice.
For armv6 support, use GRMustache 5.0.1.
The Mustache specification does not specify how a collection of objects should be rendered. For instance, the rendering of {{items}}
is unspecified if items is an array.
GRMustache 5.1 renders an array as the concatenation of the rendering of its individual items.
This makes GRMustache able to render {{items}}
just as Ruby on Rails renders <%= render @items %>
. Keep on reading.
The library was missing support for "Mustache variable lambdas", that let you execute code when rendering a plain {{variable}}
tag.
Support for variable lambdas is there now, through the GRMustacheVariableHelper
protocol.
Variable helpers are the base for "dynamic partials", that is to say the ability to defer the choice of a template partial until the actual rendering. Now your context objects can choose which partial should be rendered.
Variable helpers can also help objects being able to "render themselves", and have {{item}}
and {{items}}
rendering controlled by these items themselves.
All of those new features are documented at Guides/variable_helpers.md.
New APIs:
// The name of exceptions raised whenever the rendering could not be completed.
extern NSString * const GRMustacheRenderingException;
// Base protocol for "variable lambdas".
@protocol GRMustacheVariableHelper<NSObject>
@required
- (NSString *)renderVariable:(GRMustacheVariable *)variable;
@end
// Convenience class in order to avoid implementing a full class that conforms
// to the GRMustacheVariableHelper protocol
@interface GRMustacheVariableHelper: NSObject<GRMustacheVariableHelper>
+ (id)helperWithBlock:(NSString *(^)(GRMustacheVariable* variable))block;
@end
// Convenience class for building variable helpers that render the content of a
// template partial.
@interface GRMustacheDynamicPartial: NSObject<GRMustacheVariableHelper>
+ (id)dynamicPartialWithName:(NSString *)name;
@end
// Allows you to implement variable helpers through the GRMustacheVariableHelper
// protocol.
@interface GRMustacheVariable : NSObject
- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
- (NSString *)renderTemplateNamed:(NSString *)name error:(NSError **)outError;
@end
// This protocol is identical to the deprecated GRMustacheHelper protocol.
@protocol GRMustacheSectionHelper<NSObject>
@required
- (NSString *)renderSection:(GRMustacheSection *)section;
@end
// This class is identical to the deprecated GRMustacheHelper class.
@interface GRMustacheSectionHelper: NSObject<GRMustacheSectionHelper>
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section))block;
@end
Deprecated APIs:
// Use GRMustacheRenderingException instead
extern NSString * GRMustacheFilterException;
// Use GRMustacheSectionHelper protocol instead
@protocol GRMustacheHelper
@end
// Use GRMustacheSectionHelper class instead
@interface GRMustacheHelper
@end
Bug fixes:
- Section delegates used not to be given the rendered template as expected.
- Helpers used not to be able to render partial templates when rendering alternate template strings.
Performance improvements, and fix for flaws in the GRMustacheDelegate API.
Besides the removal of already deprecated methods, the changes introduced in this version are very unlikely to introduce incompatibilities in your code:
- Dropped support for iOS3.
- Before v5.0.0, template delegates could know that the value
Arthur
was provided by the keyname
when the tag{{name}}
is rendered. Delegates are now only provided with the value. - Before v5.0.0, a tag containing a filter expression like
{{uppercase(name)}}
would have a template delegate invoked with the rawArthur
value, not the filter result:ARTHUR
. In v5.0.0, delegate callbacks are given always given the value GRMustache is about to render.
Removed APIs:
@interface GRMustacheInvocation : NSObject
// Removed without deprecation warning
@property (nonatomic, readonly) NSString *key;
@end
@interface GRMustacheSection: NSObject
// Deprecated in v4.3.0
@property (nonatomic, retain, readonly) id renderingContext;
@end
@interface GRMustacheTemplate: NSObject
// Deprecated in v4.3.0
- (NSString *)renderObjects:(id)object, ...;
@end
// Removed without deprecation warning
GRMustacheInterpretationFilterArgument // was part of the GRMustacheInterpretation enum.
@protocol GRMustacheTemplateDelegate<NSObject>
// Deprecated in v4.1.0
- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
@end
Restored compatibility with iOS3 and OSX6 (thanks @Bertrand).
Fix a memory leak.
Bugfix: Avoid the default valueForKey:
implementation of Fundation collection classes like NSArray, NSSet and NSOrderedSet, which would return another collection. Fixes issue #21.
Bugfix: this release restores the delegate callbacks while rendering alternate template strings in helpers.
Filters allow you to process values before they are rendered, and supersede "section delegates" as the preferred way to filter values. The number formatting and array indexes.md sample codes have been updated accordingly.
New APIs:
@interface GRMustacheSection: NSObject
- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
@end
@interface GRMustacheTemplate: NSObject
+ (NSString *)renderObject:(id)object withFilters:(id)filters fromString:(NSString *)templateString error:(NSError **)outError;
+ (NSString *)renderObject:(id)object withFilters:(id)filters fromContentsOfFile:(NSString *)path error:(NSError **)outError;
+ (NSString *)renderObject:(id)object withFilters:(id)filters fromContentsOfURL:(NSURL *)url error:(NSError **)outError;
+ (NSString *)renderObject:(id)object withFilters:(id)filters fromResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError;
+ (NSString *)renderObject:(id)object withFilters:(id)filters fromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError;
- (NSString *)renderObject:(id)object withFilters:(id)filters;
- (NSString *)renderObjectsInArray:(NSArray *)objects;
- (NSString *)renderObjectsInArray:(NSArray *)objects withFilters:(id)filters;
@end
Deprecated APIs:
@interface GRMustacheSection: NSObject
// Use renderTemplateString:error: instead.
@property (nonatomic, retain, readonly) id renderingContext;
@end
@interface GRMustacheTemplate: NSObject
// Use renderObjectsInArray: instead.
- (NSString *)renderObjects:(id)object, ...;
@end
When an object that is attached to a Mustache section conforms to the GRMustacheDelegate protocol, it can observe and alter the rendering of the inner content of the section, just like the template's delegate.
This provides you with a better way to encapsulate behaviors that, with previous versions of GRMustache, would bloat the one and only delegate of a template.
Section delegates are used in the number formatting sample code, where the NSNumberFormatter class is given the opportunity to render formatted numbers.
Headers contain documentation for every exposed API.
An online reference, automatically generated from inline documentation by appledoc can be read at http://groue.github.com/GRMustache/Reference/.
A template's delegate is now able to know how a value will be interpreted by GRMustache.
New APIs:
typedef enum {
GRMustacheInterpretationSection,
GRMustacheInterpretationVariable,
} GRMustacheInterpretation;
@protocol GRMustacheTemplateDelegate<NSObject>
- (void)template:(GRMustacheTemplate *)template willInterpretReturnValueOfInvocation:(GRMustacheInvocation *)invocation as:(GRMustacheInterpretation)interpretation;
- (void)template:(GRMustacheTemplate *)template didInterpretReturnValueOfInvocation:(GRMustacheInvocation *)invocation as:(GRMustacheInterpretation)interpretation;
@end
Deprecated APIs:
@protocol GRMustacheTemplateDelegate<NSObject>
- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
@end
GRMustacheDelegate is documented in Guides/delegate.md.
The return type of -[GRMustacheTemplateRepositoryDataSource templateRepository:templateIDForName:relativeToTemplateID:]
as changed from id
to id<NSCopying>
.
GRMustacheTemplateRepositoryDataSource is documented in Guides/template_repositories.md.
GRMustache used to output badly formatted errors. They are now easier to read.
GRMustache now considers all NSNumber
instances whose boolValue
is NO
as false, when considering whether a section should render or not.
Previously, GRMustache used to consider only [NSNumber numberWithBool:NO]
as false.
This change lets you extend the mustache language with proxy objects (objects that implement language extensions, and forward other keys to some other object) in GRMustache rendering.
See Guides/sample_code/indexes.md for a discussion on proxy objects.
Whenever GRMustache performs some key lookup and valueForKey:
raises a NSUndefinedException, GRMustache swallows it and keep on looking for the key up the context stack.
Previously, GRMustache used to swallow only exceptions that explicitely came from the inquired object, and for the inquired key.
This change lets you extend the mustache language with proxy objects (objects that implement language extensions, and forward other keys to some other object) in GRMustache rendering.
See Guides/sample_code/indexes.md for a discussion on proxy objects.
Keys prefixed by a dot prevent GRMustache to look up the context stack.
Beware this feature is not in the mustache specification. If your goal is to design templates that remain compatible with other Mustache implementations, don't use this syntax.
See issue #19 and mustache/spec#10.
Restored intended architectures: armv6+armv7+i386 for libGRMustache3-iOS, i386+x86_64 for libGRMustache3-MacOS.
Removed APIs:
enum {
GRMustacheTemplateOptionNone,
GRMustacheTemplateOptionStrictBoolean
};
typedef NSUInteger GRMustacheTemplateOptions;
@interface GRMustacheTemplate: NSObject {
+ (id)templateFromString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
@end
@protocol GRMustacheTemplateRepositoryDataSource <NSObject>
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithPartialsDictionary:(NSDictionary *)partialsDictionary options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithOptions:(GRMustacheTemplateOptions)options;
@end
New APIs
enum {
// New option for processing `BOOL` and `char` properties as numbers
GRMustacheTemplateOptionStrictBoolean = 1
}
@protocol GRMustacheHelper<NSObject>
@required
// New required method
- (NSString *)renderSection:(GRMustacheSection *)section;
@end
// New GRMustacheHelper class
@interface GRMustacheHelper: NSObject<GRMustacheHelper>
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section))block;
@end
// New GRMustacheSection properties and methods
@interface GRMustacheSection: NSObject
@property (nonatomic, readonly) NSString *innerTemplateString;
@property (nonatomic, readonly) id renderingContext;
- (NSString *)render;
@end
Removed APIs and behaviors
enum {
// GRMustache is now compliant by default to the Mustache specification:
GRMustacheTemplateOptionMustacheSpecCompatibility = 1
}
// NSErrors with GRMustacheErrorDomain now store the line number in localizedDescription.
extern NSString* const GRMustacheErrorLine;
@interface GRMustache: NSObject
// This global state has been replaced by the GRMustacheTemplateOptionStrictBoolean option:
+ (BOOL)strictBooleanMode:
+ (void)setStrictBooleanMode:(BOOL)strictBooleanMode;
@end
@protocol GRMustacheHelper<NSObject>
@required
// Replaced by renderSection: method
- (NSString *)renderSection:(GRMustacheSection *)section withContext:(id)context;
@end
// Replaced by the GRMustacheHelper class:
@interface GRMustacheBlockHelper: NSObject<GRMustacheHelper> {
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section, id context))block;
@end
@interface GRMustacheSection: NSObject
// Replaced by the innerTemplateString property
@property (nonatomic, readonly) NSString *templateString;
// See the new render method
- (NSString *)renderObject:(id)object;
- (NSString *)renderObjects:(id)object, ...;
@end
GRMustache1 used to parse and interpret Handlebars tags such as {{../foo/bar}}
. GRMustache2 does no longer parse those tags.
GRMustache1 used to parse and interpret this
identifier is tags such as {{this.foo}}
. GRMustache2 does no longer parse the this
identifier.
GRMustache1 used to look for implementations of the localizeSection:inContext:
selector when rendering a {{#localize}}...{{/localize}}
section. GRMustache2 relies on the GRMustacheHelper protocol only when rendering Mustache lambda sections.
The deprecated class GRMustacheTemplateLoader was broken by 1.13.0. Deprecated does not mean unavailable: it is restored.
Deprecated class (use [GRMustacheTemplateRepository templateRepositoryWithPartialsDictionary:], or the new GRMustacheTemplateRepositoryDataSource protocol instead):
GRMustacheTemplateLoader
New class:
GRMustacheTemplateRepository
@interface GRMustacheTemplateRepository : NSObject
@property (nonatomic, assign) id<GRMustacheTemplateRepositoryDataSource> dataSource;
+ (id)templateRepository;
+ (id)templateRepositoryWithOptions:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding;
+ (id)templateRepositoryWithBaseURL:(NSURL *)URL templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path;
+ (id)templateRepositoryWithDirectory:(NSString *)path options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding;
+ (id)templateRepositoryWithDirectory:(NSString *)path templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding;
+ (id)templateRepositoryWithBundle:(NSBundle *)bundle templateExtension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateRepositoryWithPartialsDictionary:(NSDictionary *)partialsDictionary;
+ (id)templateRepositoryWithPartialsDictionary:(NSDictionary *)partialsDictionary options:(GRMustacheTemplateOptions)options;
- (GRMustacheTemplate *)templateForName:(NSString *)name error:(NSError **)outError;
- (GRMustacheTemplate *)templateFromString:(NSString *)templateString error:(NSError **)outError;
New protocol:
GRMustacheTemplateRepositoryDataSource
@protocol GRMustacheTemplateRepositoryDataSource <NSObject>
@required
- (id)templateRepository:(GRMustacheTemplateRepository *)templateRepository templateIDForName:(NSString *)name relativeToTemplateID:(id)templateID;
- (NSString *)templateRepository:(GRMustacheTemplateRepository *)templateRepository templateStringForTemplateID:(id)templateID error:(NSError **)outError;
@end
Restore parsing performances of v1.12.0
Easier template debugging with [GRMustacheInvocation description]
- GRMustacheTemplateDelegate protocol
Deprecated classes:
GRMustacheNumberFormatterHelper
GRMustacheDateFormatterHelper
BOOL property custom getters can be used to control boolean sections.
Avoid deprecation warning in GRMustache headers.
API cleanup
New GRMustacheTemplateLoader methods:
- (GRMustacheTemplate *)templateWithName:(NSString *)name error:(NSError **)outError;
- (GRMustacheTemplate *)templateFromString:(NSString *)templateString error:(NSError **)outError;
New GRMustacheTemplate methods:
+ (id)templateFromString:(NSString *)templateString error:(NSError **)outError;
+ (id)templateFromString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromContentsOfFile:(NSString *)path error:(NSError **)outError;
+ (id)templateFromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError;
+ (id)templateFromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)templateFromContentsOfURL:(NSURL *)url error:(NSError **)outError;
+ (id)templateFromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
Deprecated GRMustacheTemplateLoader methods (use templateWithName:error:
and templateFromString:error:
instead):
- (GRMustacheTemplate *)parseTemplateNamed:(NSString *)name error:(NSError **)outError;
- (GRMustacheTemplate *)parseString:(NSString *)templateString error:(NSError **)outError;
Deprecated GRMustacheTemplate methods (replace parse
with templateFrom
):
+ (id)parseString:(NSString *)templateString error:(NSError **)outError;
+ (id)parseString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseContentsOfFile:(NSString *)path error:(NSError **)outError;
+ (id)parseContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError;
+ (id)parseResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError;
+ (id)parseResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseContentsOfURL:(NSURL *)url error:(NSError **)outError;
+ (id)parseContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
Upgrade GRMustache, and get deprecation warnings when you use deprecated APIs. Your code will keep on running fine, though.
Improved Handlebars.js support
Now {{foo/bar}}
and {{foo.bar}}
syntaxes are both supported.
- Better lambda encapsulation with classes conforming to the GRMustacheHelper protocol.
- Format all numbers in a section with GRMustacheNumberFormatterHelper
- Format all dates in a section with GRMustacheDateFormatterHelper
New protocol:
GRMustacheHelper
@protocol GRMustacheHelper<NSObject>
@required
- (NSString *)renderSection:(GRMustacheSection *)section withContext:(id)context;
@end
New classes:
GRMustacheNumberFormatterHelper
GRMustacheDateFormatterHelper
@interface GRMustacheNumberFormatterHelper : NSObject<GRMustacheHelper>
@property (nonatomic, readonly, retain) NSNumberFormatter *numberFormatter;
+ (id)helperWithNumberFormatter:(NSNumberFormatter *)numberFormatter;
@end
@interface GRMustacheDateFormatterHelper : NSObject<GRMustacheHelper>
@property (nonatomic, readonly, retain) NSDateFormatter *dateFormatter;
+ (id)helperWithDateFormatter:(NSDateFormatter *)dateFormatter;
@end
Fixed bug in [GRMustacheTemplate renderObjects:...]
Added missing symbols from lib/libGRMustache1-ios3.a
Added missing symbols from lib/libGRMustache1-ios3.a and lib/libGRMustache1-ios4.a
Availability fixes.
Better testing of public API thanks to availability macros.
Bug fixes
GRMustache now supports the Mustache specification v1.1.2.
New type and enum:
enum {
GRMustacheTemplateOptionNone = 0,
GRMustacheTemplateOptionMustacheSpecCompatibility = 0x01,
};
typedef NSUInteger GRMustacheTemplateOptions;
New GRMustache methods:
+ (GRMustacheTemplateOptions)defaultTemplateOptions;
+ (void)setDefaultTemplateOptions:(GRMustacheTemplateOptions)templateOptions;
New GRMustacheTemplate methods:
+ (id)parseString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (id)parseResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromString:(NSString *)templateString options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromResource:(NSString *)name bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
+ (NSString *)renderObject:(id)object fromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options error:(NSError **)outError;
New GRMustacheTemplateLoader methods:
+ (id)templateLoaderWithBaseURL:(NSURL *)url options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithDirectory:(NSString *)path options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithDirectory:(NSString *)path extension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithDirectory:(NSString *)path extension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithBundle:(NSBundle *)bundle options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext options:(GRMustacheTemplateOptions)options;
+ (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options;
Bug fix: avoid crashing when one provides uninitialized NSError* to GRMustache.
One no longer needs to add -all_load
to the "Other Linker Flags" target option tu use GRMustache static libraries.
- Fixed issue #6
[GRMustache preventNSUndefinedKeyExceptionAttack]
no longer prevents the rendering ofnil
.
Added missing header file
GRMustache now ships as a static library.
See the Embedding wiki page in order to see how to embed GRMustache in your project.
Besides, the NSUndefinedKeyException silencing is no longer activated by the DEBUG macro. You now have to explicitely call the [GRMustache preventNSUndefinedKeyExceptionAttack]
method. For more details, see the Avoid the NSUndefinedKeyException attack wiki page.
LLVM3 compatibility
The NSUndefinedKeyException silencing activated by the DEBUG macro applies to NSManagedObject instances (see the Avoid the NSUndefinedKeyException attack wiki page).
Reduced memory footprint
New GRMustacheTemplateLoader methods:
+ (id)templateLoaderWithDirectory:(NSString *)path;
+ (id)templateLoaderWithDirectory:(NSString *)path extension:(NSString *)ext;
+ (id)templateLoaderWithDirectory:(NSString *)path extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
Deprecated GRMustacheTemplateLoader methods (replace BasePath
with Directory
):
+ (id)templateLoaderWithBasePath:(NSString *)path;
+ (id)templateLoaderWithBasePath:(NSString *)path extension:(NSString *)ext;
+ (id)templateLoaderWithBasePath:(NSString *)path extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
Bug fixes around the NSUndefinedKeyException handling when the DEBUG
macro is set (thanks to Mike Ash).
The DEBUG
macro makes GRMustache raise much less NSUndefinedKeyException (see the Avoid the NSUndefinedKeyException attack wiki page).
Bug fixes
API simplification
New GRMustacheTemplate method:
- (NSString *)renderObjects:(id)object, ...;
New GRMustacheSection method:
- (NSString *)renderObjects:(id)object, ...;
New class:
GRMustacheBlockHelper
Deprecated class (use id
instead when refering to a context, and use renderObjects:
methods instead of instanciating one):
GRMustacheContext
Deprecated function (use GRMustacheBlockHelper instead):
id GRMustacheLambdaBlockMake(NSString *(^block)(GRMustacheSection*, GRMustacheContext*));
iOS 3.0 support
New GRMustacheTemplate
methods:
+ (NSString *)renderObject:(id)object fromContentsOfFile:(NSString *)path error:(NSError **)outError;
+ (id)parseContentsOfFile:(NSString *)path error:(NSError **)outError;
New GRMustacheTemplateLoader
methods:
+ (id)templateLoaderWithBasePath:(NSString *)path;
+ (id)templateLoaderWithBasePath:(NSString *)path extension:(NSString *)ext;
+ (id)templateLoaderWithBasePath:(NSString *)path extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
Bug fixes
Bug fixes
Bug fixes
Block-less API for helpers.
New classes:
GRMustacheContext
GRMustacheSection
New functions:
id GRMustacheLambdaBlockMake(NSString *(^block)(GRMustacheSection*, GRMustacheContext*));
Deprecated functions (use GRMustacheLambdaBlockMake instead):
GRMustacheLambda GRMustacheLambdaMake(NSString *(^block)(NSString *(^)(id object), id, NSString *));
iOS 4.0 support
Deprecated class (use [NSNumber numberWithBool:YES]
instead of [GRYes yes]
):
GRYes
Deprecated class (use [NSNumber numberWithBool:NO]
instead of [GRNo no]
):
GRNo
GRMustacheTemplateLoader subclasses can now rely on an immutable extension
property.
Bug fixes
Bug fixes
Rendering performance improvement
Parsing performance improvement
Bug fixes
New methods:
[GRYes yes]
responds toboolValue
[GRNo no]
responds toboolValue
First versioned release