Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

v1.11.2

  • Loading branch information...
commit d3b562660ef3d1fe419efa141a149918de96564d 1 parent d1b3557
@groue authored
View
2  Classes/GRMustacheVersion.h
@@ -40,5 +40,5 @@
@since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 1
+#define GRMUSTACHE_PATCH_VERSION 2
View
4 RELEASE_NOTES.md
@@ -3,6 +3,10 @@ GRMustache Release Notes
You can compare the performances of GRMustache version at https://github.com/groue/GRMustacheBenchmark.
+## v1.11.2
+
+Support BOOL property custom getters. Custom BOOL getters used to be interpreted as numbers, and could not control boolean sections.
+
## v1.11.1
Avoid deprecation warning in GRMustache headers.
View
30 guides/runtime/booleans.md
@@ -55,6 +55,8 @@ For instance:
[template renderObject:alice]; // @"whistle"
[template renderObject:bob]; // @""
+Your custom property getters will work just as fine.
+
## Other false values
@@ -65,6 +67,12 @@ GRMustache considers as false the following values, and only those:
- `[NSNumber numberWithBool:NO]`, aka `kCFBooleanFalse`
- the empty string `@""`
+All those values will never be rendered with `{{name}}` tags.
+
+They all prevent Mustache sections `{{#name}}...{{/name}}` rendering.
+
+They all trigger inverted sections `{{^name}}...{{/name}}` rendering.
+
Note that zero, as an explicit NSNumber whose value is zero, or as an int/float property, is not considered false in GRMustache.
@@ -89,30 +97,10 @@ For instance, the following class would **not** render as expected:
GRMustache considers Carol as pretty, although she's not!
-That is because `BOOL` type is defined as `signed char` in `<objc/objc.h>`. Since `char` is a number, `[carol objectForKey:@"pretty"]` is `[NSNumber numberWithChar:0]`, which GRMustache considers as an actual number, and not as a falsy value.
+That is because `BOOL` type is defined as `signed char` in `<objc/objc.h>`. Since `char` is a number, `[carol objectForKey:@"pretty"]` is `[NSNumber numberWithChar:0]`, which GRMustache considers as an actual number whose value is zero, and not as a falsy value.
Objective-C properties can be analysed at runtime, and that is why GRMustache is able to nicely handle the `BOOL` property of the `Person` class. However, `BadPerson`, which defines no property, can not be applied this extra care.
-### Avoid property getters
-
-For the very same reason, you should not use your property getters in templates:
-
- @interface Person: NSObject
- @property (getter=isPretty) BOOL pretty;
- @end
-
- Person *dave = [Person new];
- dave.pretty = NO;
-
- // Note the use of the property getter, this time
- NSString *templateString = @"{{#isPretty}}whistle{{/isPretty}}";
- GRMustacheTemplate *template = [GRMustacheTemplate templateFromString:templateString error:NULL];
-
- // @"whistle"
- [template renderObject:dave];
-
-GRMustache considers Dave as pretty, although he's not! That is because there is no `isPretty` property. `isPretty` behaves just like a plain method returning BOOL, and we have seen above how GRMustache handles those.
-
### Collateral damage: signed characters properties
A consequence is that all properties declared as `char` will be considered as booleans...:
View
2  include/GRMustacheVersion.h
@@ -40,5 +40,5 @@
@since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 1
+#define GRMUSTACHE_PATCH_VERSION 2
View
BIN  lib/libGRMustache1-ios3.a
Binary file not shown
View
BIN  lib/libGRMustache1-ios4.a
Binary file not shown
View
BIN  lib/libGRMustache1-macosx10.6.a
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.