Browse files

Fix delegate.md guide so that is does not document the removed GRMust…

…acheInvocation `key` property.
  • Loading branch information...
1 parent 9286ccb commit e12baf082cfe234ff82c111c05aed02ad1c9a3bf @groue committed Sep 15, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 Guides/delegate.md
View
10 Guides/delegate.md
@@ -49,7 +49,7 @@ You can read the following properties of the *invocation* parameter:
- `id returnValue`: the return value of the invocation.
- `NSString *description`: a string that helps you locate the corresponding Mustache tag.
-Note that those methods do not allow you to build a complete "stack trace" of GRMustache rendering. They are not called for each accessed key. They are called for each tag rendering, which is quite different.
+Note that those methods do not allow you to build a complete "stack trace" of a template rendering.
For instance, a tag like `{{person.name}}` is rendered once. Thus `template:willInterpretReturnValueOfInvocation:as:` will be called once. If the person has been found, the return value will be the name of the person. If the person could not be found, the return value will be `nil`.
@@ -71,24 +71,22 @@ typedef enum {
### A practical use: debugging templates
-You may, for instance, give your templates a delegate that locate missing keys:
+You may, for instance, give your templates a delegate that locate missing values:
```objc
- (void)template:(GRMustacheTemplate *)template willInterpretReturnValueOfInvocation:(GRMustacheInvocation *)invocation as:(GRMustacheInterpretation)interpretation
{
// When returnValue is nil, GRMustache could not find any value to render.
if (invocation.returnValue == nil) {
-
- // Log the missing key
- NSLog(@"GRMustache missing key: `%@` for %@", invocation.key, invocation.description);
+ NSLog(@"GRMustache missing value for %@", invocation.description);
}
}
```
You'll get something like:
```
-GRMustache missing key: `items` for <GRMustacheInvocation: {{#items}} at line 23
+GRMustache missing value for <GRMustacheInvocation: {{#items}} at line 23
in template /path/to/template.mustache>
```

0 comments on commit e12baf0

Please sign in to comment.