Browse files

Introduce section delegates in the GRMustacheTemplate documentation

  • Loading branch information...
groue committed Jul 27, 2012
1 parent c906e00 commit 7afeec38be2d046ef4254e25a7cbc75ed59ca468
Showing with 18 additions and 1 deletion.
  1. +18 −1 Guides/
@@ -6,6 +6,21 @@ GRMustacheTemplateDelegate protocol
This protocol lets you observe, and possibly alter the rendering of a template.
+Template delegate and section delegates
+While rendering a template, several objects may get messages from GRMustache:
+- The template's delegate itself, which you set via the `delegate` property of the GRMustacheTemplate class.
+- Objects attached to sections, as long as they conform to the GRMustacheTemplateDelegate protocol.
+The template's delegate can observe the full template rendering. However, sections delegates can only observe the rendering of their inner content. As sections get nested, a template gets more and more delegates.
+Template delegates are illustrated in the [indexes sample code](sample_code/, where NSArray instances are caught before their rendering, in order to let GRMustache render indexes and other collection-related information.
+Section delegates are used in the [number formatting sample code](sample_code/, where the NSNumberFormatter class is given the opportunity to render formatted numbers.
Observe the template rendering
@@ -18,6 +33,8 @@ The following methods are called before, and after the whole template rendering:
- (void)templateDidRender:(GRMustacheTemplate *)template;
+Section delegates are not sent these messages. Only template delegates are.
### Tag rendering
The following methods are called before, and after the rendering of substitution and sections tags (`{{name}}` and `{{#name}}...{{/name}}`):
@@ -59,7 +76,7 @@ You will find an actual use of this *interpretation* parameter in the [number fo
### A practical use: debugging templates
-You may, for instance, locate keys that could not find any data:
+You may, for instance, give your templates a delegate that locate missing keys:
- (void)template:(GRMustacheTemplate *)template willInterpretReturnValueOfInvocation:(GRMustacheInvocation *)invocation as:(GRMustacheInterpretation)interpretation

0 comments on commit 7afeec3

Please sign in to comment.