You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark.
Performance improvements and API simplification
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
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 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.
Performance improvements
Performance improvements
Improved Handlebars.js support and performance improvements
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 AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
@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
Template compiling performance improvement
Bug fixes
New methods:
[GRYes yes]
responds toboolValue
[GRNo no]
responds toboolValue
First versioned release