Navigation Menu

Skip to content

Commit

Permalink
More GFM :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Mar 5, 2012
1 parent 0132163 commit f009128
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions guides/delegate.md
Expand Up @@ -15,22 +15,28 @@ Observe the template rendering

The protocol allows you to observe the rendering of a whole template:

- `- (void)templateWillRender:(GRMustacheTemplate *)template;`
- `- (void)templateDidRender:(GRMustacheTemplate *)template;`
```objc
- (void)templateWillRender:(GRMustacheTemplate *)template;
- (void)templateDidRender:(GRMustacheTemplate *)template;
```

Two other methods allow to observe the rendering of Mustache tags:

- `- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;`
- `- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;`
```objc
- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation;
```

Maybe verbose. But quite on target.

Those methods are called before and after GRMustache renders the result of an *invocation*. As a matter of fact, in order to render `{{name}}` or `{{#name}}...{{/name}}`, GRMustache has to *invoke* `name` on the rendered object, the one you've given to the template. The return value may be, for instance, "Eric Paul".

You can read the following properties of the *invocation* argument:

- `@property (nonatomic, readonly) NSString *key;`
- `@property (nonatomic, retain) id returnValue;`
```objc
@property (nonatomic, readonly) NSString *key;
@property (nonatomic, retain) id returnValue;
```

`returnValue` will give you the return value (`@"Eric Paul"`, in our example). `key` contains the key that did provide this value (`@"name"`, in our example).

Expand Down

0 comments on commit f009128

Please sign in to comment.