Skip to content

Commit

Permalink
more GRMustacheTemplateDelegate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Mar 5, 2012
1 parent 16f24a3 commit 0bebc11
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions guides/delegate.md
Expand Up @@ -64,21 +64,14 @@ The `returnValue` property of the *invocation* argument can be written. If you s
**Warning: If your goal is to design templates that remain compatible with [other Mustache implementations](https://github.com/defunkt/mustache/wiki/Other-Mustache-implementations), don't use this feature.**


### A practical use: more debugging templates

Let's improve the targetting of missing keys by rendering a big visible value in the template where there should have been some correct data:
### A practical use: providing default values for missing keys

```objc
- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation
{
// When returnValue is nil, GRMustache could not find any value to render.
if (invocation.returnValue == nil) {
// Log the missing key...
NSLog(@"GRMustache missing key: %@", invocation.key);
// ...and render a big visible value so that we can't miss it.
invocation.returnValue = @"[MISSING]";
invocation.returnValue = @"[DEFAULT]";
}
}
```
Expand Down

0 comments on commit 0bebc11

Please sign in to comment.