Skip to content

Commit

Permalink
Make clear in guide that variable tag helpers can also be delegates.
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Oct 12, 2012
1 parent 1a7b646 commit 26f510c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions Guides/delegate.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ GRMustacheTemplateDelegate protocol
This protocol lets you observe, and possibly alter the rendering of a template.


Template delegate and section delegates
---------------------------------------
Template delegate and tag 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 section tags, as long as they conform to the GRMustacheTemplateDelegate protocol.
- Objects attached to section and variable tags, as long as they conform to the GRMustacheTemplateDelegate protocol.

The template's delegate can observe the full template rendering. However, Delegates of section tags can only observe the rendering of their inner content. As sections get nested, a template gets more and more delegates.
The template's delegate can observe the full template rendering.

Section tag delegates can only observe the rendering of their inner content. As sections get nested, a template would get more and more delegates.

[Variable tag helpers](variable_tag_helpers.md) can also be delegates, and observe their own rendering.

You'll find template delegate usages below. Delegates of section tags are used in the [localization](sample_code/localization.md) sample code.

Expand All @@ -31,7 +35,7 @@ The following methods are called before, and after the whole template rendering:
- (void)templateDidRender:(GRMustacheTemplate *)template;
```

Delegates of section tags are not sent these messages. Only template delegates are.
Tag delegates are not sent these messages. Only template delegates are.

### Tag rendering

Expand Down Expand Up @@ -124,7 +128,7 @@ GRMustacheTemplateDelegate will help you when you can not, or do not want, to em
Sample code
-----------

The [localization.md](sample_code/localization.md) sample code uses delegates of section tags for localizing portions of a template.
The [localization.md](sample_code/localization.md) sample code uses section tag delegate for localizing portions of a template.


[up](introduction.md), [next](../../../tree/master/Guides/sample_code)
2 changes: 1 addition & 1 deletion Guides/sample_code/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ The [GRMustacheDelegate](../delegate.md) protocol is a nifty tool: it lets you k

This looks like a nice way to build our format arguments and the localizable format string in a single strike: instead of letting GRMustache render `Arthur` and `Barbara`, we'll put those values away, and tell the library to render `%@` instead.

We'll thus now attach to the `localize` section an object that conforms to *both* the `GRMustacheSectionTagHelper` and `GRMustacheTemplateDelegate` protocols. As in the previous example, we'll perform a "double-pass" rendering: the first rendering will use the delegate side, build the localizable format string, and fill the format arguments. The second rendering will simply mix the format and the arguments.
We'll thus now attach to the `localize` section an object that conforms to *both* the `GRMustacheSectionTagHelper` and `GRMustacheTemplateDelegate` protocols. As in the previous example, we'll perform a "double-pass" rendering: the first rendering will use the delegate facet, build the localizable format string, and fill the format arguments. The second rendering will simply mix the format and the arguments.

Now the convenient `[GRMustacheSectionTagHelper helperWithBlock:]` method is not enough. Let's go for a full class:

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can compare the performances of GRMustache versions at https://github.com/gr

## v5.4.3

Until this version, GRMustache would not trigger section tag helpers, variable tag helpers and section delegates in a few corner cases.
Until this version, GRMustache would not trigger section tag helpers, variable tag helpers and tag delegates in a few corner cases.

## v5.4.2

Expand Down
2 changes: 1 addition & 1 deletion src/classes/GRMustacheRuntime_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern BOOL GRMustacheRuntimeDidCatchNSUndefinedKeyException;
* - provide the current context object.
* - perform a key lookup in the context stack.
* - perform a key lookup in the filter stack.
* - let template and section delegates interpret rendered values.
* - let template and tag delegates interpret rendered values.
*/
@interface GRMustacheRuntime : NSObject {
BOOL _parentHasContext;
Expand Down

0 comments on commit 26f510c

Please sign in to comment.