Permalink
Browse files

More GFM :-)

  • Loading branch information...
1 parent 0132163 commit f009128ca0fbfd7537b72e2b79c3feb6785d33c8 @groue committed Mar 5, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 guides/delegate.md
View
@@ -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).

0 comments on commit f009128

Please sign in to comment.