Skip to content

Commit

Permalink
v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Apr 3, 2012
1 parent ad48484 commit eb5cff8
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 156 deletions.
25 changes: 1 addition & 24 deletions Guides/runtime/booleans.md
Expand Up @@ -102,30 +102,7 @@ A consequence is that all properties declared as `char` will be considered as bo
@end @end
``` ```


We thought that built-in support for `BOOL` properties was worth this annoyance, since it should be pretty rare that you would use a value of such a type in a template. We thought that built-in support for `BOOL` properties was worth this annoyance, since it should be pretty rare that you would use a value of such a type in a template.

However, should this behavior annoy you, we provide a mechanism for having GRMustache consider `char` and `BOOL` properties as what they really are: numbers.

Use the `GRMustacheTemplateOptionStrictBoolean` option when loading and rendering templates:

```objc
Person *alice = [Person new];
alice.pretty = NO;

// All the following renderings return @"whistle", because alice's pretty property is now considered as a number.

// On-the-fly rendering:
[GRMustacheTemplate renderObject:alice fromString:templateString options:GRMustacheTemplateOptionStrictBoolean];

// With a GRMustacheTemplate:
GRMustacheTemplate *template = [GRMustacheTemplate templateFromString:templateString options:GRMustacheTemplateOptionStrictBoolean error:NULL];
[template renderObject:alice];

// With a GRMustacheTemplate loaded from a GRMustacheTemplateRepository:
GRMustacheTemplateRepository *templateRepository = [GRMustacheTemplateRepository templateRepositoryWith... options:GRMustacheTemplateOptionStrictBoolean];
GRMustacheTemplate *template = [templateRepository templateFromString:templateString error:NULL];
[template renderObject:alice];
```




### The case for C99 bool ### The case for C99 bool
Expand Down
42 changes: 42 additions & 0 deletions RELEASE_NOTES.md
Expand Up @@ -3,6 +3,48 @@ GRMustache Release Notes


You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark. You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark.


## v3.0.0

**There is no option**

Removed APIs:

```objc
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
```
## v2.0.0 ## v2.0.0
**Performance improvements and API simplification** **Performance improvements and API simplification**
Expand Down
37 changes: 2 additions & 35 deletions include/GRMustache.h
Expand Up @@ -23,14 +23,6 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "GRMustacheAvailabilityMacros.h" #import "GRMustacheAvailabilityMacros.h"


enum {
GRMustacheTemplateOptionNone = 0,
GRMustacheTemplateOptionStrictBoolean = 0x01,
};

typedef NSUInteger GRMustacheTemplateOptions;


/** /**
A C struct that hold GRMustache version information A C struct that hold GRMustache version information
Expand Down Expand Up @@ -60,7 +52,7 @@ typedef struct {
@return The version of GRMustache as a GRMustacheVersion struct. @return The version of GRMustache as a GRMustacheVersion struct.
@since v1.0 @since v1.0
*/ */
+ (GRMustacheVersion)version AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; + (GRMustacheVersion)version AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;


////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
/// @name Preventing NSUndefinedKeyException when using GRMustache in Development configuration /// @name Preventing NSUndefinedKeyException when using GRMustache in Development configuration
Expand All @@ -83,32 +75,7 @@ typedef struct {
@since v1.7 @since v1.7
*/ */
+ (void)preventNSUndefinedKeyExceptionAttack AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; + (void)preventNSUndefinedKeyExceptionAttack AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;


//////////////////////////////////////////////////////////////////////////////////////////
/// @name Global template options
//////////////////////////////////////////////////////////////////////////////////////////

/**
Returns the default template options. The default value is GRMustacheTemplateOptionNone.
@return The default template options. The default value is GRMustacheTemplateOptionNone.
@see setDefaultTemplateOptions:
@since v1.8
*/
+ (GRMustacheTemplateOptions)defaultTemplateOptions AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER;

/**
Sets the default template options.
Those options will be used by all GRMustacheTemplate rendering and parsing methods, such as [GRMustacheTemplate templateFromString:error:] and [GRMustacheTemplate renderObject:fromString:error:].
@param templateOptions A mask of options indicating the default behavior of templates.
@see defaultTemplateOptions
@since v1.8
*/
+ (void)setDefaultTemplateOptions:(GRMustacheTemplateOptions)templateOptions AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER;


@end @end


Expand Down
30 changes: 15 additions & 15 deletions include/GRMustacheAvailabilityMacros.h
Expand Up @@ -28,18 +28,18 @@
/* /*
* Set up standard GRMustache versions * Set up standard GRMustache versions
*/ */
#define GRMUSTACHE_VERSION_2_0 2000 #define GRMUSTACHE_VERSION_3_0 3000












/* /*
* If max GRMustacheVersion not specified, assume 2.0 * If max GRMustacheVersion not specified, assume 3.0
*/ */
#ifndef GRMUSTACHE_VERSION_MAX_ALLOWED #ifndef GRMUSTACHE_VERSION_MAX_ALLOWED
#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_2_0 #define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_3_0
#endif #endif


/* /*
Expand All @@ -55,8 +55,8 @@
#if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_MIN_REQUIRED #if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_MIN_REQUIRED
#error GRMUSTACHE_VERSION_MAX_ALLOWED must be >= GRMUSTACHE_VERSION_MIN_REQUIRED #error GRMUSTACHE_VERSION_MAX_ALLOWED must be >= GRMUSTACHE_VERSION_MIN_REQUIRED
#endif #endif
#if GRMUSTACHE_VERSION_MIN_REQUIRED < GRMUSTACHE_VERSION_2_0 #if GRMUSTACHE_VERSION_MIN_REQUIRED < GRMUSTACHE_VERSION_3_0
#error GRMUSTACHE_VERSION_MIN_REQUIRED must be >= GRMUSTACHE_VERSION_2_0 #error GRMUSTACHE_VERSION_MIN_REQUIRED must be >= GRMUSTACHE_VERSION_3_0
#endif #endif




Expand All @@ -65,26 +65,26 @@




/* /*
* AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER * AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER
* *
* Used on declarations introduced in GRMustache 2.0 * Used on declarations introduced in GRMustache 3.0
*/ */
#define AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER #define AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER


/* /*
* AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER_BUT_DEPRECATED * AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER_BUT_DEPRECATED
* *
* Used on declarations introduced in GRMustache 2.0, * Used on declarations introduced in GRMustache 3.0,
* and deprecated in GRMustache 2.0 * and deprecated in GRMustache 3.0
*/ */
#define AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE #define AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE


/* /*
* DEPRECATED_IN_GRMUSTACHE_VERSION_2_0_AND_LATER * DEPRECATED_IN_GRMUSTACHE_VERSION_3_0_AND_LATER
* *
* Used on types deprecated in GRMustache 2.0 * Used on types deprecated in GRMustache 3.0
*/ */
#define DEPRECATED_IN_GRMUSTACHE_VERSION_2_0_AND_LATER DEPRECATED_ATTRIBUTE #define DEPRECATED_IN_GRMUSTACHE_VERSION_3_0_AND_LATER DEPRECATED_ATTRIBUTE






Expand Down
4 changes: 2 additions & 2 deletions include/GRMustacheError.h
Expand Up @@ -29,7 +29,7 @@
@since v1.0 @since v1.0
*/ */
extern NSString* const GRMustacheErrorDomain AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; extern NSString* const GRMustacheErrorDomain AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;


/** /**
The codes of a GRMustache-generated NSError The codes of a GRMustache-generated NSError
Expand All @@ -50,6 +50,6 @@ typedef enum {
@since v1.0 @since v1.0
*/ */
GRMustacheErrorCodeTemplateNotFound, GRMustacheErrorCodeTemplateNotFound,
} GRMustacheErrorCode AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; } GRMustacheErrorCode AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;




4 changes: 2 additions & 2 deletions include/GRMustacheHelper.h
Expand Up @@ -31,7 +31,7 @@


@protocol GRMustacheHelper<NSObject> @protocol GRMustacheHelper<NSObject>
@required @required
- (NSString *)renderSection:(GRMustacheSection *)section AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; - (NSString *)renderSection:(GRMustacheSection *)section AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;
@end @end




Expand All @@ -41,7 +41,7 @@
#if NS_BLOCKS_AVAILABLE #if NS_BLOCKS_AVAILABLE


@interface GRMustacheHelper: NSObject<GRMustacheHelper> @interface GRMustacheHelper: NSObject<GRMustacheHelper>
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section))block AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; + (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section))block AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;
@end @end


#endif /* if NS_BLOCKS_AVAILABLE */ #endif /* if NS_BLOCKS_AVAILABLE */
4 changes: 2 additions & 2 deletions include/GRMustacheInvocation.h
Expand Up @@ -28,6 +28,6 @@
id _returnValue; id _returnValue;
id _token; id _token;
} }
@property (nonatomic, readonly) NSString *key AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; @property (nonatomic, readonly) NSString *key AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;
@property (nonatomic, retain) id returnValue AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; @property (nonatomic, retain) id returnValue AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;
@end @end
6 changes: 3 additions & 3 deletions include/GRMustacheSection.h
Expand Up @@ -47,7 +47,7 @@
@since v2.0 @since v2.0
*/ */
@property (nonatomic, readonly) id renderingContext AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; @property (nonatomic, readonly) id renderingContext AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;






Expand All @@ -61,7 +61,7 @@
@since v2.0 @since v2.0
*/ */
@property (nonatomic, readonly) NSString *innerTemplateString AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; @property (nonatomic, readonly) NSString *innerTemplateString AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;




////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -75,6 +75,6 @@
@since v2.0 @since v2.0
*/ */
- (NSString *)render AVAILABLE_GRMUSTACHE_VERSION_2_0_AND_LATER; - (NSString *)render AVAILABLE_GRMUSTACHE_VERSION_3_0_AND_LATER;


@end @end

0 comments on commit eb5cff8

Please sign in to comment.