Skip to content

Commit

Permalink
Let {{tag}} render kCFBooleanFalse and empty array, remove obsolete t…
Browse files Browse the repository at this point in the history
…ests, update Guides/runtime/booleans.md
  • Loading branch information
groue committed Apr 1, 2012
1 parent b44b9c3 commit d796a61
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 26 deletions.
2 changes: 0 additions & 2 deletions Guides/runtime/booleans.md
Expand Up @@ -58,8 +58,6 @@ GRMustache considers as false the following values, and only those:
- the empty string `@""`
- empty enumerables (all objects conforming to the NSFastEnumeration protocol, but NSDictionary -- the most obvious enumerable is NSArray).

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.
Expand Down
4 changes: 0 additions & 4 deletions src/classes/GRMustacheTemplate.m
Expand Up @@ -263,10 +263,6 @@ + (GRMustacheObjectKind)objectKind:(id)object
}
}

+ (BOOL)objectShouldBeRendered:(id)object
{
return (object && (object != [NSNull null]) && ((void *)object != (void *)kCFBooleanFalse));
}

#pragma mark <GRMustacheRenderingElement>

Expand Down
1 change: 0 additions & 1 deletion src/classes/GRMustacheTemplate_private.h
Expand Up @@ -42,7 +42,6 @@ typedef enum {
#pragma mark Objects kinds

+ (GRMustacheObjectKind)objectKind:(id)object GRMUSTACHE_API_INTERNAL;
+ (BOOL)objectShouldBeRendered:(id)object GRMUSTACHE_API_INTERNAL;

#pragma mark Delegate

Expand Down
2 changes: 1 addition & 1 deletion src/classes/GRMustacheVariableElement.m
Expand Up @@ -64,7 +64,7 @@ - (NSString *)renderContext:(GRMustacheContext *)context inRootTemplate:(GRMusta
// interpret

NSString *result = nil;
if([GRMustacheTemplate objectShouldBeRendered:value]) {
if (value && (value != [NSNull null])) {
result = [value description];
if (!_raw) {
result = [self htmlEscape:result];
Expand Down
18 changes: 0 additions & 18 deletions src/tests/Public/v2.0/GRMustacheSuites/variables.json
Expand Up @@ -58,24 +58,6 @@
"template": "<{{subject}}>",
"expected": "<>"
},
{
"name": "False should not be rendered.",
"data": { "subject": false },
"template": "<{{subject}}>",
"expected": "<>"
},
{
"name": "Empty string should not be rendered.",
"data": { "subject": "" },
"template": "<{{subject}}>",
"expected": "<>"
},
{
"name": "Empty list should not be rendered.",
"data": { "subject": [] },
"template": "<{{subject}}>",
"expected": "<>"
},

// Whitespace Insensitivity

Expand Down

0 comments on commit d796a61

Please sign in to comment.