Skip to content
Browse files

v5.3.0

  • Loading branch information...
1 parent c651e63 commit ed26c8517dfbf945f48fa08ddeab2246d4255518 @groue committed Sep 26, 2012
Showing with 2,586 additions and 702 deletions.
  1. +2 −2 AppledocSettings.plist
  2. +2 −2 Articles/WhyMustacheFilters.md
  3. +10 −10 Guides/delegate.md
  4. +11 −5 Guides/forking.md
  5. +6 −8 Guides/helpers.md
  6. +5 −5 Guides/introduction.md
  7. +1 −1 Guides/runtime.md
  8. +2 −2 Guides/runtime/booleans.md
  9. +20 −20 Guides/sample_code/localization.md
  10. +10 −10 Guides/sample_code/localization/GRMustacheLocalization/GRAppDelegate.m
  11. +1 −187 Guides/section_helpers.md
  12. +187 −0 Guides/section_tag_helpers.md
  13. +2 −2 Guides/templates.md
  14. +1 −268 Guides/variable_helpers.md
  15. +284 −0 Guides/variable_tag_helpers.md
  16. +4 −4 README.md
  17. +48 −1 RELEASE_NOTES.md
  18. +2 −2 Reference/html/Classes/GRMustache.html
  19. +2 −2 Reference/html/Classes/GRMustacheFilter.html
  20. +4 −3 Reference/html/Classes/GRMustacheHelper.html
  21. +2 −2 Reference/html/Classes/GRMustacheInvocation.html
  22. +10 −7 Reference/html/Classes/GRMustacheSection.html
  23. +5 −4 Reference/html/Classes/GRMustacheSectionHelper.html
  24. +29 −29 Reference/html/Classes/{GRMustacheDynamicPartial.html → GRMustacheSectionTagHelper.html}
  25. +482 −0 Reference/html/Classes/GRMustacheSectionTagRenderingContext.html
  26. +175 −6 Reference/html/Classes/GRMustacheTemplate.html
  27. +2 −2 Reference/html/Classes/GRMustacheTemplateRepository.html
  28. +8 −6 Reference/html/Classes/GRMustacheVariable.html
  29. +3 −3 Reference/html/Classes/GRMustacheVariableHelper.html
  30. +410 −0 Reference/html/Classes/GRMustacheVariableTagRenderingContext.html
  31. +2 −2 Reference/html/Protocols/GRMustacheFilter.html
  32. +2 −2 Reference/html/Protocols/GRMustacheHelper.html
  33. +8 −5 Reference/html/Protocols/GRMustacheSectionHelper.html
  34. +336 −0 Reference/html/Protocols/GRMustacheSectionTagHelper.html
  35. +2 −2 Reference/html/Protocols/GRMustacheTemplateDelegate.html
  36. +2 −2 Reference/html/Protocols/GRMustacheTemplateRepositoryDataSource.html
  37. +8 −5 Reference/html/Protocols/GRMustacheVariableHelper.html
  38. +13 −7 Reference/html/hierarchy.html
  39. +13 −7 Reference/html/index.html
  40. +12 −4 include/GRMustache.h
  41. +80 −2 include/GRMustacheAvailabilityMacros.h
  42. +10 −6 include/GRMustacheSection.h
  43. +15 −7 include/GRMustacheSectionHelper.h
  44. +98 −0 include/GRMustacheSectionTagHelper.h
  45. +90 −0 include/GRMustacheSectionTagRenderingContext.h
  46. +36 −3 include/GRMustacheTemplate.h
  47. +33 −8 include/GRMustacheTemplateDelegate.h
  48. +8 −5 include/GRMustacheVariable.h
  49. +12 −40 include/GRMustacheVariableHelper.h
  50. +74 −0 include/GRMustacheVariableTagRenderingContext.h
  51. +1 −1 include/GRMustacheVersion.h
  52. BIN lib/libGRMustache5-MacOS.a
  53. BIN lib/libGRMustache5-iOS.a
  54. +1 −1 src/classes/GRMustacheVersion.h
View
4 AppledocSettings.plist
@@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>--project-name</key>
- <string>GRMustache 5.2</string>
+ <string>GRMustache 5.3</string>
<key>--project-version</key>
- <string>5.2</string>
+ <string>5.3</string>
<key>--project-company</key>
<string>Gwendal Roué</string>
<key>--create-html</key>
View
4 Articles/WhyMustacheFilters.md
@@ -58,7 +58,7 @@ Since filters are not tied to the view model, they are *reusable*.
There are major differences between *expressions* and *statements*. Statements chain, one after the other, independently, and can not provide any value. Statements *perform* and return nothing. Expressions are a different kind of beast: by essence, they provide *values*, and can be *composed* from other expressions.
-Obviously, Mustache needs values: substitution tags need a value that they can render, section tags need a value that they can test, loop, or make enter the context stack. Since only expressions provide with values, they are what Mustache need.
+Obviously, Mustache needs values: variable tags need a value that they can render, section tags need a value that they can test, loop, or make enter the context stack. Since only expressions provide with values, they are what Mustache need.
Mustache already has two kinds of expressions: keys and key paths. `name` is a key. `person.name` is a key path. Both expressions evaluate in a different manner. The key expression looks in the context stack for an object that would provide the "name" key. The key path expression looks in the context stack for an object that would provide the "person" key, and then extract the "name" key right from this person. The latter behavior is called a "scoped lookup".
@@ -183,7 +183,7 @@ after the other, until it reaches the *VALID*, *EMPTY*, or *INVALID* state:
### Filtered variables, filtered sections
-Expressions as a way for the library user to build values that would be rendered by Mustache. Now those values are actually rendered as variables (substitution tags) tags, or sections.
+Expressions as a way for the library user to build values that would be rendered by Mustache. Now those values are actually rendered by variable tags, or section tags.
The only argument so far I've read against filtered sections is: "I see no compelling use case that need this feature".
View
20 Guides/delegate.md
@@ -12,11 +12,11 @@ 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.
+- Objects attached to section tags, 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.
+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.
-You'll find template delegate usages below. Section delegates are used in the [localization](sample_code/localization.md) sample code.
+You'll find template delegate usages below. Delegates of section tags are used in the [localization](sample_code/localization.md) sample code.
Observe the template rendering
@@ -31,11 +31,11 @@ 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.
+Delegates of section tags 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}}`):
+The following methods are called before, and after the rendering of variable and sections tags (`{{name}}` and `{{#name}}...{{/name}}`):
```objc
- (void)template:(GRMustacheTemplate *)template willInterpretReturnValueOfInvocation:(GRMustacheInvocation *)invocation as:(GRMustacheInterpretation)interpretation;
@@ -59,14 +59,14 @@ The *interpretation* parameter tells you how the return value of the invocation
```objc
typedef enum {
- GRMustacheInterpretationSection,
- GRMustacheInterpretationVariable,
+ GRMustacheSectionTagInterpretation,
+ GRMustacheVariableTagInterpretation,
} GRMustacheInterpretation;
```
-`GRMustacheInterpretationVariable` tells you that the return value is rendered by a Mustache variable tag such as `{{name}}`. Basically, GRMustache simply invokes its `description` method. See [Guides/runtime.md](runtime.md) for more information.
+`GRMustacheVariableTagInterpretation` tells you that the return value is rendered by a Mustache variable tag such as `{{name}}`. Basically, GRMustache simply invokes its `description` method. See [Guides/runtime.md](runtime.md) for more information.
-`GRMustacheInterpretationSection` tells you that the return value is used by a Mustache section such as `{{#name}}...{{/name}}`. Mustache sections are versatile: there are boolean sections, loop sections, and lambda sections, and this depends solely on the rendered value, that is to say: the return value of the invocation. Again, see [Guides/runtime.md](runtime.md) for more information.
+`GRMustacheSectionTagInterpretation` tells you that the return value is used by a Mustache section tag such as `{{#name}}...{{/name}}`. Mustache sections are versatile: there are boolean sections, loop sections, and lambda sections, and this depends solely on the rendered value, that is to say: the return value of the invocation. Again, see [Guides/runtime.md](runtime.md) for more information.
### A practical use: debugging templates
@@ -122,7 +122,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 section delegates for localizing portions of template.
+The [localization.md](sample_code/localization.md) sample code uses delegates of section tags for localizing portions of a template.
[up](introduction.md), [next](../../../tree/master/Guides/sample_code)
View
16 Guides/forking.md
@@ -48,7 +48,7 @@ The library features are described in the [guides](introduction.md). This sectio
The *compiler* consumes a parse tree of tokens and outputs an [abstract syntax tree](http://en.wikipedia.org/wiki/Abstract_syntax_tree) of *rendering elements*.
- Rendering elements are actually able to provide the rendering expected by the library user. *Templates* render full templates and partials, *section elements* render Mustache sections, *text elements* render raw text, and *variable elements* perform variable substitution.
+ Rendering elements are actually able to provide the rendering expected by the library user. *Templates* render full templates and partials, *section elements* render Mustache section tags, *text elements* render raw text, and *variable elements* render Mustache variable tags.
For instance, from the tokens parsed from `Hello {{name}}!`, a compiler outputs an AST made of one template containing two text elements and a variable element.
@@ -67,11 +67,17 @@ The library features are described in the [guides](introduction.md). This sectio
*Invocations* are created by runtime objects, and exposed to *delegates*, so that the library user inspect or override rendered values.
-- **Lambda sections**
- - `GRMustacheHelper`
- - `GRMustacheSection`
+- **Lambdas Sections**
+ - `GRMustacheSectionTagHelper`
+ - `GRMustacheSectionTagRenderingContext`
- The library user can implement *helpers* in order to have some sections behave as "Mustache lambda sections". In order to be able to perform the job described by the Mustache specification, they are provided with *section* objects that provide the required information and tools.
+ The library user can implement *section tag helpers* in order to have some section tags behave as "Mustache lambdas". In order to be able to perform the job described by the Mustache specification, they are provided with *rendering context* objects that provide the required information and tools.
+
+- **Lambdas Variables**
+ - `GRMustacheVariableTagHelper`
+ - `GRMustacheVariableTagRenderingContext`
+
+ The library user can implement *variable tag helpers* in order to have some variable tags behave as "Mustache lambdas". In order to be able to perform the job described by the Mustache specification, they are provided with *rendering context* objects that provide the required information and tools.
- **Filters**
- `GRMustacheFilter`
View
14 Guides/helpers.md
@@ -1,15 +1,13 @@
-[up](introduction.md), [next](section_helpers.md)
+[up](introduction.md), [next](section_tag_helpers.md)
Helpers
=======
-GRMustache allows you to implement "Mustache lambdas", that is to say sections and variable tags that render in your own fashion.
+Section tag helpers let you render a section tag as `{{#name}}...{{/name}}` with your own custom code.
-Section helpers let you attach code to a section `{{#name}}...{{/name}}`.
+Variable tag helpers let you render a variable tag as: `{{name}}` with you own code as well.
-Variable helpers let you attach code to a variable `{{name}}`.
+- [Section tag helpers](section_tag_helpers.md)
+- [Variable tag helpers](variable_tag_helpers.md)
-- [Section helpers](section_helpers.md)
-- [Variable helpers](section_helpers.md)
-
-[up](introduction.md), [next](section_helpers.md)
+[up](introduction.md), [next](section_tag_helpers.md)
View
10 Guides/introduction.md
@@ -10,11 +10,11 @@ Features
### Core Mustache
-- **variables**, as `{{name}}` and `{{{name}}}` (HTML-escaped or not)
-- **sections** (boolean, loop, lambda, inverted), as `{{#name}}...{{/name}}` and `{{^name}}...{{/name}}`
-- **partial templates inclusion**, including recursive partials, as `{{> partial}}`
-- **comments**, as `{{! comment }}`
-- "**set delimiter**" tags, as `{{=<% %>=}}`
+- **variable tags**, as `{{name}}` and `{{{name}}}` (HTML-escaped or not)
+- **section tags** (boolean, loop, lambda, inverted), as `{{#name}}...{{/name}}` and `{{^name}}...{{/name}}`
+- **partial tags**, as `{{> partial}}`
+- **comment tag**, as `{{! comment }}`
+- "**set delimiter tags**", as `{{=<% %>=}}`
### Overlooked Mustache
View
2 Guides/runtime.md
@@ -32,7 +32,7 @@ Mustache does a little more than rendering plain `{{name}}` tags. Let's review M
- [context_stack.md](runtime/context_stack.md)
- This guide digs into Mustache sections such as `{{#section}}...{{/section}}`, and the key lookup mechanism.
+ This guide digs into Mustache section tags such as `{{#section}}...{{/section}}`, and the key lookup mechanism.
- [loops.md](runtime/loops.md)
View
4 Guides/runtime/booleans.md
@@ -1,4 +1,4 @@
-[up](../runtime.md), [next](../section_helpers.md)
+[up](../runtime.md), [next](../section_tag_helpers.md)
# Booleans
@@ -60,4 +60,4 @@ They all prevent Mustache sections `{{#name}}...{{/name}}` rendering.
They all trigger inverted sections `{{^name}}...{{/name}}` rendering.
-[up](../runtime.md), [next](../section_helpers.md)
+[up](../runtime.md), [next](../section_tag_helpers.md)
View
40 Guides/sample_code/localization.md
@@ -8,7 +8,7 @@ Overview
Mustache and GRMustache have no built-in localization feature. It is thus a matter of injecting our own application code into the template rendering, some code that localizes its input.
-[Mustache lambda sections](../section_helpers.md) are our vector. We'll eventually render the following template:
+[Section tag helpers](../section_tag_helpers.md) are our vector. We'll eventually render the following template:
{{#localize}}
Hello {{name1}}, do you know {{name2}}?
@@ -51,14 +51,14 @@ And render, depending on the current locale:
Bonjour
Hola
-We'll execute our localizing code by attaching to the `localize` section an object that conforms to the `GRMustacheSectionHelper` protocol.
+We'll execute our localizing code by attaching to the `localize` section an object that conforms to the `GRMustacheSectionTagHelper` protocol.
-The shortest way to build a helper is the `[GRMustacheSectionHelper helperWithBlock:]` method. Its block is given a `GRMustacheSection` object whose `innerTemplateString` property perfectly suits our needs:
+The shortest way to build a helper is the `[GRMustacheSectionTagHelper helperWithBlock:]` method. Its block is given a `GRMustacheSectionTagRenderingContext` object whose `innerTemplateString` property perfectly suits our needs:
```objc
id data = @{
- @"localize": [GRMustacheSectionHelper helperWithBlock:^(GRMustacheSection *section) {
- return NSLocalizedString(section.innerTemplateString, nil);
+ @"localize": [GRMustacheSectionTagHelper helperWithBlock:^(GRMustacheSectionTagRenderingContext *context) {
+ return NSLocalizedString(context.innerTemplateString, nil);
}]
};
@@ -70,7 +70,7 @@ NSString *rendering = [GRMustacheTemplate renderObject:data
error:NULL];
```
-`GRMustacheSectionHelper` and `innerTemplateString` are documented in the [section_helpers.md](../section_helpers.md) guide.
+`GRMustacheSectionTagHelper` and `innerTemplateString` are documented in the [section_tag_helpers.md](../section_tag_helpers.md) guide.
Localizing a value
@@ -92,17 +92,17 @@ Rendering:
Bonjour
Hola
-Again, we'll execute our localizing code by attaching to the `localize` section an object that conforms to the `GRMustacheSectionHelper` protocol.
+Again, we'll execute our localizing code by attaching to the `localize` section an object that conforms to the `GRMustacheSectionTagHelper` protocol.
However, this time, we are not localizing a raw portion of the template. Instead, we are localizing a value that comes from the rendered data.
-Fortunately, `GRMustacheSection` objects are able to provide helpers with the rendering of their inner content, `"Hello"` in our case, with their `render` method:
+Fortunately, `GRMustacheSectionTagRenderingContext` objects are able to provide helpers with the rendering of their inner content, `"Hello"` in our case, with their `render` method:
```objc
id data = @{
@"greeting": @"Hello",
- @"localize": [GRMustacheSectionHelper helperWithBlock:^(GRMustacheSection *section) {
- return NSLocalizedString([section render], nil);
+ @"localize": [GRMustacheSectionTagHelper helperWithBlock:^(GRMustacheSectionTagRenderingContext *context) {
+ return NSLocalizedString([context render], nil);
}]
};
@@ -116,7 +116,7 @@ NSString *rendering = [GRMustacheTemplate renderObject:data
You can see this as a "double-pass" rendering: the section is rendered once, in order to turn `{{greeting}}` into `Hello`, and the localization of this string is eventually inserted in the final rendering.
-`GRMustacheSectionHelper` and `[GRMustacheSection render]` are documented in the [section_helpers.md](../section_helpers.md) guide.
+`GRMustacheSectionTagHelper` and `[GRMustacheSectionTagRenderingContext render]` are documented in the [section_tag_helpers.md](../section_tag_helpers.md) guide.
Localizing a template section with arguments
@@ -169,29 +169,29 @@ 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 `GRMustacheSectionHelper` 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 side, build the localizable format string, and fill the format arguments. The second rendering will simply mix the format and the arguments.
-Now the convenient `[GRMustacheSectionHelper helperWithBlock:]` method is not enough. Let's go for a full class:
+Now the convenient `[GRMustacheSectionTagHelper helperWithBlock:]` method is not enough. Let's go for a full class:
```objc
-@interface LocalizatingHelper : NSObject<GRMustacheSectionHelper, GRMustacheTemplateDelegate>
+@interface LocalizatingHelper : NSObject<GRMustacheSectionTagHelper, GRMustacheTemplateDelegate>
@property (nonatomic, strong) NSMutableArray *formatArguments;
@end
@implementation LocalizatingHelper
/**
- * GRMustacheSectionHelper method
+ * GRMustacheSectionTagHelper method
*/
-- (NSString *)renderSection:(GRMustacheSection *)section
+- (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context
{
/**
* Let's perform a first rendering of the section, invoking
- * [section render].
+ * [context render].
*
- * This method returns the rendering of the section
- * ("Hello {{name1}}! Do you know {{name2}}?" in our specific example).
+ * This method returns the rendering of the section:
+ * "Hello {{name1}}! Do you know {{name2}}?" in our specific example.
*
* Normally, it would return "Hello Arthur! Do you know Barbara?", which
* we could not localize.
@@ -214,7 +214,7 @@ Now the convenient `[GRMustacheSectionHelper helperWithBlock:]` method is not en
*/
self.formatArguments = [NSMutableArray array];
- NSString *localizableFormat = [section render]; // triggers delegate callbacks
+ NSString *localizableFormat = [context render]; // triggers delegate callbacks
/**
View
20 Guides/sample_code/localization/GRMustacheLocalization/GRAppDelegate.m
@@ -23,7 +23,7 @@
#import "GRAppDelegate.h"
#import "GRMustache.h"
-@interface LocalizatingHelper : NSObject<GRMustacheSectionHelper, GRMustacheTemplateDelegate>
+@interface LocalizatingHelper : NSObject<GRMustacheSectionTagHelper, GRMustacheTemplateDelegate>
@end
@implementation GRAppDelegate
@@ -36,8 +36,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
*/
id data = @{
- @"localize": [GRMustacheSectionHelper helperWithBlock:^NSString *(GRMustacheSection *section) {
- return NSLocalizedString(section.innerTemplateString, nil);
+ @"localize": [GRMustacheSectionTagHelper helperWithBlock:^NSString *(GRMustacheSectionTagRenderingContext *context) {
+ return NSLocalizedString(context.innerTemplateString, nil);
}]
};
@@ -54,8 +54,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
id data = @{
@"greeting": @"Hello",
- @"localize": [GRMustacheSectionHelper helperWithBlock:^NSString *(GRMustacheSection *section) {
- return NSLocalizedString([section render], nil);
+ @"localize": [GRMustacheSectionTagHelper helperWithBlock:^NSString *(GRMustacheSectionTagRenderingContext *context) {
+ return NSLocalizedString([context render], nil);
}]
};
@@ -96,14 +96,14 @@ @interface LocalizatingHelper()
@implementation LocalizatingHelper
-- (NSString *)renderSection:(GRMustacheSection *)section
+- (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context
{
/**
* Let's perform a first rendering of the section, invoking
- * [section render].
+ * [context render].
*
- * This method returns the rendering of the section
- * ("Hello {{name1}}! Do you know {{name2}}?" in our specific example).
+ * This method returns the rendering of the section:
+ * "Hello {{name1}}! Do you know {{name2}}?" in our specific example.
*
* Normally, it would return "Hello Arthur! Do you know Barbara?", which
* we could not localize.
@@ -126,7 +126,7 @@ - (NSString *)renderSection:(GRMustacheSection *)section
*/
self.formatArguments = [NSMutableArray array];
- NSString *localizableFormat = [section render]; // triggers delegate callbacks
+ NSString *localizableFormat = [context render]; // triggers delegate callbacks
/**
View
188 Guides/section_helpers.md
@@ -1,187 +1 @@
-[up](introduction.md), [next](variable_helpers.md)
-
-Section Helpers
-===============
-
-GRMustache helpers allow you to implement "Mustache lambda sections", that is to say sections that render in your own fashion.
-
-
-Overview
---------
-
-When GRMustache renders a section `{{#name}}...{{/name}}`, it looks for the `name` key in the [context stack](runtime/context_stack.md), using the standard Key-Value Coding `valueForKey:` method. GRMustache may find a string, an [array](runtime/loops.md), a [boolean](runtime/booleans.md), whatever, or a *section helper*. It's here a matter of attaching code, instead of regular values, to the keys of your data objects.
-
-GRMustache recognizes a section helper when it finds an object that conforms to the `GRMustacheSectionHelper` protocol.
-
-
-### GRMustacheSectionHelper protocol and class
-
-This protocol is defined as:
-
-```objc
-@protocol GRMustacheSectionHelper <NSObject>
-@required
-- (NSString *)renderSection:(GRMustacheSection *)section;
-@end
-```
-
-This `renderSection:` method will be called when the helper is asked to render the section is it attached to. Its result will be directly inserted in the final rendering.
-
-The protocol comes with a `GRMustacheSectionHelper` class, which provides a convenient method for building a helper without implementing a full class that conforms to the protocol:
-
-```objc
-@interface GRMustacheSectionHelper: NSObject<GRMustacheSectionHelper>
-+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section))block;
-@end
-```
-
-Just like the `renderSection:` protocol method, the block takes a section and returns the rendering. In most cases, this is the easiest way to write a helper.
-
-The `GRMustacheSection` parameter represents the section attached to a helper. It provides the following methods:
-
-```objc
-@interface GRMustacheSection: NSObject
-@property (nonatomic, readonly) NSString *innerTemplateString;
-- (NSString *)render;
-- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
-@end
-```
-
-The `innerTemplateString` property contains the *raw template string* inside the section, the `...` in `{{#lambda}}...{{/lambda}}`. In the inner template string, `{{tags}}` will not have been interpolated: you'll get the raw template string.
-
-The `render` method returns the *rendering of the inner content* of the section, just as if the helper was not here. `{{tags}}` are, this time, interpolated in the current context. This allows helper to perform "double-pass" rendering, by performing a first "classical" Mustache rendering followed by some post-processing.
-
-The `renderTemplateString:error:` returns the *rendering of an alternate content* for the section. The eventual `{{tags}}` in the alternate content are, again, interpolated. Should you provide a template string with a syntax error, or that loads a missing template partial, the method would return nil, and sets its error argument.
-
-Let's see a few examples.
-
-
-Examples
---------
-
-### Section helper example: wrapping a section's content
-
-Let's write a helper which wraps its section:
-
-Template:
-
- {{#wrapped}}
- {{name}} is awesome.
- {{/wrapped}}
-
-Data:
-
-```objc
-id data = @{
- @"name": @"Arthur",
- @"wrapped": [GRMustacheSectionHelper helperWithBlock:^(GRMustacheSection *section) {
- NSString *rawRendering = [section render];
- return [NSString stringWithFormat:@"<b>%@</b>", rawRendering];
- }]};
-```
-
-Render:
-
- <b>Arthur is awesome.</b>
-
-```objc
-NSString *rendering = [template renderObject:data];
-```
-
-This wrapper helper performs a *double-pass rendering*: The `[section render]` would return the rendering of the inner content, that is to say, `Arthur is awesome.`.
-
-The helper then returns this raw rendering wrapped inside a HTML `<b>` tag, which enters the final rendering.
-
-
-### Section helper example: Have a section render an alternate template string
-
-For the purpose of demonstration, we'll implement a helper that turns a portion of a template into a HTML link.
-
-Template:
-
- {{#movie}}
- {{#link}}{{title}}{{/link}}
- {{#director}}
- by {{#link}}{{firstName}} {{lastName}}{{/link}}
- {{/director}}
- {{/movie}}
-
-Data:
-
-```objc
-id data = @{
- @"movie": @{
- @"url": @"/movies/123",
- @"title": @"Citizen Kane",
- @"director": @{
- @"url": @"/people/321",
- @"firstName": @"Orson",
- @"lastName": @"Welles",
- }
- },
- @"link": [GRMustacheSectionHelper helperWithBlock:^(GRMustacheSection *section) {
- NSString *format = @"<a href=\"{{url}}\">%@</a>";
- NSString *templateString = [NSString stringWithFormat:format, section.innerTemplateString];
- return [section renderTemplateString:templateString error:NULL];
- }]
-}
-```
-
-Render:
-
- <a href="/movies/123">Citizen Kane</a>
- by <a href="/people/321">Orson Welles</a>
-
-```objc
-NSString *rendering = [template renderObject:data];
-```
-
-This helper again performs a *double-pass rendering*:
-
-It first wraps the inner template string (`{{title}}`, or `{{firstName}} {{lastName}}`) inside a HTML link, whose url is *also expressed* as a Mustache tag. This gives the two alternate template strings: `<a href="{{url}}">{{title}}</a>` and `<a href="{{url}}">{{firstName}} {{lastName}}</a>`.
-
-Since both movie and director data objects contain values for the `url` key, the renderings of those alternate template string embed the URL of Citizen Kane and of its director.
-
-
-Providing section helpers aside
--------------------------------
-
-All the examples above use an ad-hoc NSDictionary for filling the template. This dictionary contains both values and helpers.
-
-However, generally, your data will not come from dictionaries, but from your *model objects*. And you don't want to pollute them with Mustache helpers:
-
-```objc
-Movie *movie = ...;
-
-// How to provide the `link` helper?
-NSString *rendering = [template renderObject:movie];
-```
-
-The solution is the `renderObjectsInArray:` method of GRMustacheTemplate. Simply provide an array filled with you helper, and your model object:
-
-```objc
-Movie *movie = ...;
-id helpers = @{ @"link": [GRMustacheSectionHelper ...] };
-NSString *rendering = [template renderObjectsInArray:@[helpers, movie]];
-```
-
-
-GRMustache helpers vs. Mustache lambdas
----------------------------------------
-
-**Warning: If your goal is to design GRMustache helpers that remain compatible with Mustache lambdas of [other Mustache implementations](https://github.com/defunkt/mustache/wiki/Other-Mustache-implementations), read the following with great care.**
-
-The strings returned by GRMustache helpers are directly inserted in the final rendering, without any further processing.
-
-However, the specification [states](https://github.com/mustache/spec/blob/v1.1.2/specs/%7Elambdas.yml#L90) that "Lambdas used for sections should have their results parsed" (read, processed as a Mustache template, and rendered in the current context).
-
-In order to comply with the genuine Mustache behavior, a section helper MUST return the result of the `renderTemplateString:error:` method of its _section_ parameter, as the linking helper seen above, and a variable helper MUST return the result of a method of its _variable_ parameter.
-
-
-Sample code
------------
-
-The [localization.md](sample_code/localization.md) sample code uses section helpers for localizing portions of template.
-
-
-[up](introduction.md), [next](variable_helpers.md)
+This document has [moved](section_tag_helpers.md).
View
187 Guides/section_tag_helpers.md
@@ -0,0 +1,187 @@
+[up](introduction.md), [next](variable_tag_helpers.md)
+
+Section Tag Helpers
+===================
+
+Section tag helpers allow you to render a Mustache section such as `{{#name}}...{{/name}}` with you own custom code.
+
+
+Overview
+--------
+
+When GRMustache renders a section `{{#name}}...{{/name}}`, it looks for the `name` key in the [context stack](runtime/context_stack.md), using the standard Key-Value Coding `valueForKey:` method. GRMustache may find a string, an [array](runtime/loops.md), a [boolean](runtime/booleans.md), whatever, or a *section tag helper*. It's here a matter of attaching code, instead of regular values, to the keys of your data objects.
+
+GRMustache recognizes a section tag helper when it finds an object that conforms to the `GRMustacheSectionTagHelper` protocol.
+
+
+### GRMustacheSectionTagHelper protocol and class
+
+This protocol is defined as:
+
+```objc
+@protocol GRMustacheSectionTagHelper <NSObject>
+@required
+- (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context;
+@end
+```
+
+This `renderForSectionTagInContext:` method will be called when the helper is asked to render the section is it attached to. Its result will be directly inserted in the final rendering.
+
+The protocol comes with a `GRMustacheSectionTagHelper` class, which provides a convenient method for building a helper without implementing a full class that conforms to the protocol:
+
+```objc
+@interface GRMustacheSectionTagHelper: NSObject<GRMustacheSectionTagHelper>
++ (id)helperWithBlock:(NSString *(^)(GRMustacheSectionTagRenderingContext* context))block;
+@end
+```
+
+Just like the `renderForSectionTagInContext:` protocol method, the block takes a context and returns the rendering. In most cases, this is the easiest way to write a helper.
+
+The `GRMustacheSectionTagRenderingContext` parameter provides the following methods:
+
+```objc
+@interface GRMustacheSectionTagRenderingContext: NSObject
+@property (nonatomic, readonly) NSString *innerTemplateString;
+- (NSString *)render;
+- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
+@end
+```
+
+The `innerTemplateString` property contains the *raw template string* inside the section, the `...` in `{{#lambda}}...{{/lambda}}`. In the inner template string, `{{tags}}` will not have been interpolated: you'll get the raw template string.
+
+The `render` method returns the *rendering of the inner content* of the section, just as if the helper was not here. `{{tags}}` are, this time, interpolated in the current context. This allows helper to perform "double-pass" rendering, by performing a first "classical" Mustache rendering followed by some post-processing.
+
+The `renderTemplateString:error:` returns the *rendering of an alternate content*. The eventual `{{tags}}` in the alternate content are, again, interpolated. Should you provide a template string with a syntax error, or that loads a missing template partial, the method would return nil, and sets its error argument.
+
+Let's see a few examples.
+
+
+Examples
+--------
+
+### Wrapping a section's content
+
+Let's write a helper which wraps its section:
+
+Template:
+
+ {{#wrapped}}
+ {{name}} is awesome.
+ {{/wrapped}}
+
+Data:
+
+```objc
+id data = @{
+ @"name": @"Arthur",
+ @"wrapped": [GRMustacheSectionTagHelper helperWithBlock:^(GRMustacheSectionTagRenderingContext *context) {
+ NSString *rawRendering = [context render];
+ return [NSString stringWithFormat:@"<b>%@</b>", rawRendering];
+ }]};
+```
+
+Render:
+
+ <b>Arthur is awesome.</b>
+
+```objc
+NSString *rendering = [template renderObject:data];
+```
+
+This wrapper helper performs a *double-pass rendering*: The `[context render]` would return the rendering of the inner content, that is to say, `Arthur is awesome.`.
+
+The helper then returns this raw rendering wrapped inside a HTML `<b>` tag, which enters the final rendering.
+
+
+### Have a section render an alternate template string
+
+For the purpose of demonstration, we'll implement a helper that turns a portion of a template into a HTML link.
+
+Template:
+
+ {{#movie}}
+ {{#link}}{{title}}{{/link}}
+ {{#director}}
+ by {{#link}}{{firstName}} {{lastName}}{{/link}}
+ {{/director}}
+ {{/movie}}
+
+Data:
+
+```objc
+id data = @{
+ @"movie": @{
+ @"url": @"/movies/123",
+ @"title": @"Citizen Kane",
+ @"director": @{
+ @"url": @"/people/321",
+ @"firstName": @"Orson",
+ @"lastName": @"Welles",
+ }
+ },
+ @"link": [GRMustacheSectionTagHelper helperWithBlock:^(GRMustacheSectionTagRenderingContext *context) {
+ NSString *format = @"<a href=\"{{url}}\">%@</a>";
+ NSString *templateString = [NSString stringWithFormat:format, context.innerTemplateString];
+ return [context renderTemplateString:templateString error:NULL];
+ }]
+}
+```
+
+Render:
+
+ <a href="/movies/123">Citizen Kane</a>
+ by <a href="/people/321">Orson Welles</a>
+
+```objc
+NSString *rendering = [template renderObject:data];
+```
+
+This helper again performs a *double-pass rendering*:
+
+It first wraps the inner template string (`{{title}}`, or `{{firstName}} {{lastName}}`) inside a HTML link, whose url is *also expressed* as a Mustache tag. This gives the two alternate template strings: `<a href="{{url}}">{{title}}</a>` and `<a href="{{url}}">{{firstName}} {{lastName}}</a>`.
+
+Since both movie and director data objects contain values for the `url` key, the renderings of those alternate template string embed the URL of Citizen Kane and of its director.
+
+
+Providing section tag helpers aside
+-----------------------------------
+
+All the examples above use an ad-hoc NSDictionary for filling the template. This dictionary contains both values and helpers.
+
+However, generally, your data will not come from dictionaries, but from your *model objects*. And you don't want to pollute them with Mustache helpers:
+
+```objc
+Movie *movie = ...;
+
+// How to provide the `link` helper?
+NSString *rendering = [template renderObject:movie];
+```
+
+The solution is the `renderObjectsFromArray:` method of GRMustacheTemplate. Simply provide an array filled with you helper, and your model object:
+
+```objc
+Movie *movie = ...;
+id helpers = @{ @"link": [GRMustacheSectionTagHelper ...] };
+NSString *rendering = [template renderObjectsFromArray:@[helpers, movie]];
+```
+
+
+GRMustache helpers vs. Mustache lambdas
+---------------------------------------
+
+**Warning: If your goal is to design GRMustache helpers that remain compatible with Mustache lambdas of [other Mustache implementations](https://github.com/defunkt/mustache/wiki/Other-Mustache-implementations), read the following with great care.**
+
+The strings returned by GRMustache helpers are directly inserted in the final rendering, without any further processing.
+
+However, the specification [states](https://github.com/mustache/spec/blob/v1.1.2/specs/%7Elambdas.yml#L90) that "Lambdas used for sections should have their results parsed" (read, processed as a Mustache template, and rendered in the current context).
+
+In order to comply with the genuine Mustache behavior, a section tag helper MUST return the result of the `renderTemplateString:error:` method of its _section_ parameter, as the linking helper seen above, and a variable tag helper MUST return the result of a method of its _variable_ parameter.
+
+
+Sample code
+-----------
+
+The [localization.md](sample_code/localization.md) sample code uses section tag helpers for localizing portions of template.
+
+
+[up](introduction.md), [next](variable_tag_helpers.md)
View
4 Guides/templates.md
@@ -105,10 +105,10 @@ On success, those methods return GRMustacheTemplate instances, which render obje
```objc
- (NSString *)renderObject:(id)object;
-- (NSString *)renderObjectsInArray:(NSArray *)objects
+- (NSString *)renderObjectsFromArray:(NSArray *)objects
```
-The latter method, which takes several arguments, is helpful when several objects should feed the template.
+The latter method, which takes an array of objects, is helpful when several objects should feed the template.
More loading options
View
269 Guides/variable_helpers.md
@@ -1,268 +1 @@
-[up](introduction.md), [next](filters.md)
-
-Variable Helpers
-================
-
-GRMustache helpers allow you to implement "Mustache lambda variables", that is to say variable tags that render in your own fashion.
-
-
-Overview
---------
-
-When GRMustache renders a variable tag `{{name}}`, it looks for the `name` key in the [context stack](runtime/context_stack.md), using the standard Key-Value Coding `valueForKey:` method. GRMustache may find a string, an [array](runtime/loops.md), a [boolean](runtime/booleans.md), whatever, or a *variable helper*. It's here a matter of attaching code, instead of regular values, to the keys of your data objects.
-
-GRMustache recognizes a variable helper when it finds an object that conforms to the `GRMustacheVariableHelper` protocol.
-
-
-### GRMustacheVariableHelper protocol and class
-
-This protocol is defined as:
-
-```objc
-@protocol GRMustacheVariableHelper<NSObject>
-@required
-- (NSString *)renderVariable:(GRMustacheVariable *)variable;
-@end
-```
-
-This `renderVariable:` method will be called when the helper is asked to render the variable tag is it attached to. Its result will be directly inserted in the final rendering, *without any HTML escaping*, regardless of the number of braces in the template. More on that below.
-
-The protocol comes with a `GRMustacheVariableHelper` class, which provides a convenient method for building a helper without implementing a full class that conforms to the protocol:
-
-```objc
-@interface GRMustacheVariableHelper: NSObject<GRMustacheVariableHelper>
-+ (id)helperWithBlock:(NSString *(^)(GRMustacheVariable* variable))block;
-@end
-```
-
-Just like the `renderVariable:` protocol method, the block takes a variable and returns the rendering. In most cases, this is the easiest way to write a helper.
-
-The `GRMustacheVariable` parameter represents the variable attached to a helper. It provides the following methods:
-
-```objc
-@interface GRMustacheVariable : NSObject
-- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
-- (NSString *)renderTemplateNamed:(NSString *)name error:(NSError **)outError;
-@end
-```
-The `renderTemplateString:error:` method returns the *rendering of a template string*. The eventual `{{tags}}` in the template string are interpolated in the current context. Should you provide a template string with a syntax error, or that loads a missing template partial, the method would return nil, and sets its error argument.
-
-The `renderTemplateNamed:error:` method is a shortcut that returns the *rendering of a partial template*, given its name.
-
-
-### Purpose of variable helpers
-
-Variable helpers are designed to let you send simple variable tags on steroids. Let's see an example, based on the story of a very short template snippet:
-
- by {{author}}
-
-Let's assume, for the purpose of the demonstration, that this template is shared among several Mustache applications: an iOS app, an Android app, a website: you can *not* change it freely.
-
-The 1st iteration of your application simply renders a person name:
-
-```objc
-id data = @{ @"author": person.name };
-
-// by Orson Welles
-NSString *rendering = [template render:data];
-```
-
-2nd iteration of your application should now render a link to the person instead of its plain name. Remember: the template can not change. How would we do?
-
-Variable lambdas to the rescue!
-
-```objc
-id data = @{
- @"author_url": person.url
- @"author_name": person.name
- @"author": [GRMustacheVariableHelper helperWithBlock:^(GRMustacheVariable *variable) {
- return [variable renderTemplateString:@"<a href=\"{{author_url}}\">{{author_name}}</a>" error:NULL];
- }]
-};
-
-// by <a href="...">Orson Welles</a>
-NSString *rendering = [template render:data];
-```
-
-Using this technique, you can still safely HTML-escape your values, while performing a complex rendering out from a simple variable tag.
-
-Now you understand why the output of variable lambdas is not HTML-escaped: your lambdas use rendering APIs that already provide HTML escaping.
-
-
-#### Dynamic partials
-
-You may not want to embed inline templates in your code, and keep them in partial templates. The example above could be rewritten this way:
-
-```objc
-id data = @{
- @"author_url": person.url
- @"author_name": person.name
- // author.mustache contains `<a href="{{author_url}}">{{author_name}}</a>`
- @"author": [GRMustacheVariableHelper helperWithBlock:^(GRMustacheVariable *variable) {
- return [variable renderTemplateNamed:@"author" error:NULL];
- }]
-};
-
-// by <a href="...">Orson Welles</a>
-NSString *rendering = [template render:data];
-```
-
-Since this pattern should be common, the library ships with the `GRMustacheDynamicPartial` class, which is less verbose:
-
-```objc
-id data = @{
- @"author_url": person.url
- @"author_name": person.name
- @"author": [GRMustacheDynamicPartial dynamicPartialWithName:@"author"]
-};
-
-// by <a href="...">Orson Welles</a>
-NSString *rendering = [template render:data];
-```
-
-However, keep in mind the longer version that uses `renderTemplateNamed:error:`, that we'll find again in the final example.
-
-Examples
---------
-
-### Variable helper example: have a variable expand into a template string
-
-Template:
-
- {{#movie}}
- {{link}}
- {{#director}}
- by {{link}}
- {{/director}}
- {{/movie}}
-
-Data:
-
-```objc
-NSString *movieLinkTemplateString = @"<a href=\"{{url}}\">{{title}}</a>";
-NSString *directorLinkTemplateString = @"<a href=\"{{url}}\">{{firstName}} {{lastName}}</a>";
-id data = @{
- @"movie": @{
- @"url": @"/movies/123",
- @"title": @"Citizen Kane",
- @"link": [GRMustacheVariableHelper helperWithBlock:^(GRMustacheVariable *variable) {
- return [variable renderTemplateString:movieLinkTemplateString error:NULL];
- }],
- @"director": @{
- @"url": @"/people/321",
- @"firstName": @"Orson",
- @"lastName": @"Welles",
- @"link": [GRMustacheVariableHelper helperWithBlock:^(GRMustacheVariable *variable) {
- return [variable renderTemplateString:directorLinkTemplateString error:NULL];
- }],
- }
- }
-}
-```
-
-Render:
-
- <a href="/movies/123">Citizen Kane</a>
- by <a href="/people/321">Orson Welles</a>
-
-```objc
-NSString *rendering = [template renderObject:data];
-```
-
-
-### Variable helper example: have a variable expand into a partial template
-
-Templates:
-
- base.mustache
- {{#items}}
- - {{link}}
- {{/items}}
-
- movie_link.mustache
- <a href="{{url}}">{{title}}</a>
-
- director_link.mustache
- <a href="{{url}}">{{firstName}} {{lastName}}</a>
-
-Data:
-
-```objc
-id data = @{
- @"items": @[
- @{ // movie
- @"url": @"/movies/123",
- @"title": @"Citizen Kane",
- @"link": [GRMustacheDynamicPartial dynamicPartialWithName:@"movie_link"],
- },
- @{ // director
- @"url": @"/people/321",
- @"firstName": @"Orson",
- @"lastName": @"Welles",
- @"link": [GRMustacheDynamicPartial dynamicPartialWithName:@"director_link"],
- }
- ]
-};
-```
-
-Render:
-
- - <a href="/movies/123">Citizen Kane</a>
- - <a href="/people/321">Orson Welles</a>
-
-```objc
-NSString *rendering = [template renderObject:data];
-```
-
-
-### Variable helper example: have objects able to "render themselves"
-
-Templates:
-
- base.mustache
- {{movie}}
-
- movie.mustache
- {{title}} by {{director}}
-
- person.mustache
- {{firstName}} {{lastName}}
-
-Data:
-
-```objc
-Person *orson = [Person personWithFirstName:@"Orson" lastName:@"Welles"];
-Movie *movie = [Movie movieWithTitle:@"Citizen Kane" director:orson];
-id data = @{ @"movie": movie };
-```
-
-Render:
-
- Citizen Kane by Orson Welles
-
-```objc
-NSString *rendering = [template renderObject:data];
-```
-
-This works because Movie and Person classes conform to the GRMustacheVariableHelper protocol. Let's assume their core interface is already defined, and let's focus on their rendering:
-
-```objc
-@implementation Movie
-// A movie renders itself with the movie.mustache partial template.
-- (NSString *)renderVariable:(GRMustacheVariable *)variable
-{
- return [variable renderTemplateNamed:@"movie" error:NULL];
-}
-@end
-
-@implementation Person
-// A person renders itself with the person.mustache partial template.
-- (NSString *)renderVariable:(GRMustacheVariable *)variable
-{
- return [variable renderTemplateNamed:@"person" error:NULL];
-}
-@end
-```
-
-
-[up](introduction.md), [next](filters.md)
+This document has [moved](variable_tag_helpers.md).
View
284 Guides/variable_tag_helpers.md
@@ -0,0 +1,284 @@
+[up](introduction.md), [next](filters.md)
+
+Variable Tag Helpers
+====================
+
+Variable tag helpers allow you to render a Mustache variable tag such as `{{name}}` with you own custom code.
+
+
+Overview
+--------
+
+When GRMustache renders a variable tag `{{name}}`, it looks for the `name` key in the [context stack](runtime/context_stack.md), using the standard Key-Value Coding `valueForKey:` method. GRMustache may find a string, an [array](runtime/loops.md), a [boolean](runtime/booleans.md), whatever, or a *variable tag helper*. It's here a matter of attaching code, instead of regular values, to the keys of your data objects.
+
+GRMustache recognizes a variable tag helper when it finds an object that conforms to the `GRMustacheVariableTagHelper` protocol.
+
+
+### GRMustacheVariableTagHelper protocol and class
+
+This protocol is defined as:
+
+```objc
+@protocol GRMustacheVariableTagHelper<NSObject>
+@required
+- (NSString *)renderForVariableTagInContext:(GRMustacheVariableTagRenderingContext *)context;
+@end
+```
+
+This `renderForVariableTagInContext:` method will be called when the helper is asked to render the variable tag is it attached to. Its result will be directly inserted in the final rendering, *without any HTML escaping*, regardless of the number of braces in the template. More on that below.
+
+The protocol comes with a `GRMustacheVariableTagHelper` class, which provides a convenient method for building a helper without implementing a full class that conforms to the protocol:
+
+```objc
+@interface GRMustacheVariableTagHelper: NSObject<GRMustacheVariableTagHelper>
++ (id)helperWithBlock:(NSString *(^)(GRMustacheVariableTagRenderingContext* context))block;
+@end
+```
+
+Just like the `renderForVariableTagInContext:` protocol method, the block takes a context and returns the rendering. In most cases, this is the easiest way to write a helper.
+
+The `GRMustacheVariableTagRenderingContext` parameter provides the following methods:
+
+```objc
+@interface GRMustacheVariableTagRenderingContext : NSObject
+- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError;
+- (NSString *)renderTemplateNamed:(NSString *)name error:(NSError **)outError;
+@end
+```
+The `renderTemplateString:error:` method returns the *rendering of a template string*. The eventual `{{tags}}` in the template string are interpolated. Should you provide a template string with a syntax error, or that loads a missing template partial, the method would return nil, and sets its error argument.
+
+The `renderTemplateNamed:error:` method is a shortcut that returns the *rendering of a partial template*, given its name.
+
+
+### Purpose of variable tag helpers
+
+Variable tag helpers are designed to let you send simple variable tags on steroids. Let's see an example, based on the story of a very short template snippet:
+
+ by {{author}}
+
+Let's assume, for the purpose of the demonstration, that this template is shared among several Mustache applications: an iOS app, an Android app, a website: you can *not* change it freely.
+
+The 1st iteration of your application simply renders a person name:
+
+```objc
+id data = @{ @"author": person.name };
+
+// by Orson Welles
+NSString *rendering = [template render:data];
+```
+
+2nd iteration of your application should now render a link to the person instead of its plain name. Remember: the template can not change. How would we do?
+
+Variable tag helpers to the rescue!
+
+```objc
+id data = @{
+ @"author_url": person.url
+ @"author_name": person.name
+ @"author": [GRMustacheVariableTagHelper helperWithBlock:^(GRMustacheVariableTagRenderingContext *context) {
+ return [context renderTemplateString:@"<a href=\"{{author_url}}\">{{author_name}}</a>" error:NULL];
+ }]
+};
+
+// by <a href="...">Orson Welles</a>
+NSString *rendering = [template render:data];
+```
+
+Using this technique, you can still safely HTML-escape your values, while performing a complex rendering out from a simple variable tag.
+
+Now you understand why the output of variable tag helpers is not HTML-escaped: your helpers use rendering APIs that already provide HTML escaping.
+
+
+#### Dynamic partials
+
+You may not want to embed inline templates in your code, and keep them in partial templates. The example above could be rewritten this way:
+
+```objc
+id data = @{
+ @"author_url": person.url
+ @"author_name": person.name
+ // author.mustache contains `<a href="{{author_url}}">{{author_name}}</a>`
+ @"author": [GRMustacheVariableTagHelper helperWithBlock:^(GRMustacheVariableTagRenderingContext *context) {
+ return [context renderTemplateNamed:@"author" error:NULL];
+ }]
+};
+
+// by <a href="...">Orson Welles</a>
+NSString *rendering = [template render:data];
+```
+
+Since this pattern should be common, the library ships with the `GRMustacheDynamicPartial` class, which is less verbose:
+
+```objc
+id data = @{
+ @"author_url": person.url
+ @"author_name": person.name
+ @"author": [GRMustacheDynamicPartial dynamicPartialWithName:@"author"]
+};
+
+// by <a href="...">Orson Welles</a>
+NSString *rendering = [template render:data];
+```
+
+However, keep in mind the longer version that uses `renderTemplateNamed:error:`, that we'll find again in the final example.
+
+Examples
+--------
+
+### Have a variable tag expand into a template string
+
+Template:
+
+ {{#movie}}
+ {{link}}
+ {{#director}}
+ by {{link}}
+ {{/director}}
+ {{/movie}}
+
+Data:
+
+```objc
+NSString *movieLinkTemplateString = @"<a href=\"{{url}}\">{{title}}</a>";
+NSString *directorLinkTemplateString = @"<a href=\"{{url}}\">{{firstName}} {{lastName}}</a>";
+id data = @{
+ @"movie": @{
+ @"url": @"/movies/123",
+ @"title": @"Citizen Kane",
+ @"link": [GRMustacheVariableTagHelper helperWithBlock:^(GRMustacheVariableTagRenderingContext *context) {
+ return [context renderTemplateString:movieLinkTemplateString error:NULL];
+ }],
+ @"director": @{
+ @"url": @"/people/321",
+ @"firstName": @"Orson",
+ @"lastName": @"Welles",
+ @"link": [GRMustacheVariableTagHelper helperWithBlock:^(GRMustacheVariableTagRenderingContext *context) {
+ return [context renderTemplateString:directorLinkTemplateString error:NULL];
+ }],
+ }
+ }
+}
+```
+
+Render:
+
+ <a href="/movies/123">Citizen Kane</a>
+ by <a href="/people/321">Orson Welles</a>
+
+```objc
+NSString *rendering = [template renderObject:data];
+```
+
+
+### Have a variable tag expand into a partial template
+
+Templates:
+
+ base.mustache
+ {{#items}}
+ - {{link}}
+ {{/items}}
+
+ movie_link.mustache
+ <a href="{{url}}">{{title}}</a>
+
+ director_link.mustache
+ <a href="{{url}}">{{firstName}} {{lastName}}</a>
+
+Data:
+
+```objc
+id data = @{
+ @"items": @[
+ @{ // movie
+ @"url": @"/movies/123",
+ @"title": @"Citizen Kane",
+ @"link": [GRMustacheDynamicPartial dynamicPartialWithName:@"movie_link"],
+ },
+ @{ // director
+ @"url": @"/people/321",
+ @"firstName": @"Orson",
+ @"lastName": @"Welles",
+ @"link": [GRMustacheDynamicPartial dynamicPartialWithName:@"director_link"],
+ }
+ ]
+};
+```
+
+Render:
+
+ - <a href="/movies/123">Citizen Kane</a>
+ - <a href="/people/321">Orson Welles</a>
+
+```objc
+NSString *rendering = [template renderObject:data];
+```
+
+
+### Have objects able to "render themselves"
+
+Templates:
+
+ base.mustache
+ {{movie}}
+
+ movie.mustache
+ {{title}} by {{director}}
+
+ person.mustache
+ {{firstName}} {{lastName}}
+
+Data:
+
+```objc
+Person *orson = [Person personWithFirstName:@"Orson" lastName:@"Welles"];
+Movie *movie = [Movie movieWithTitle:@"Citizen Kane" director:orson];
+id data = @{ @"movie": movie };
+```
+
+Render:
+
+ Citizen Kane by Orson Welles
+
+```objc
+NSString *rendering = [template renderObject:data];
+```
+
+How can this work? Let's assume the core interface of our Movie and Person classes is already defined, and let's have them render themselves with a partial:
+
+```objc
+
+// Declare categories on our classes so that they conform to the
+// GRMustacheVariableTagHelper protocol.
+
+@interface Movie(GRMustache)<GRMustacheVariableTagHelper>
+@end
+
+@interface Person(GRMustache)<GRMustacheVariableTagHelper>
+@end
+
+// And now implement the protocol:
+
+@implementation Movie
+
+- (NSString *)renderForVariableTagInContext:(GRMustacheVariableTagRenderingContext *)context
+{
+ // Render the "movie.mustache" partial
+ return [context renderTemplateNamed:@"movie" error:NULL];
+}
+
+@end
+
+@implementation Person
+
+- (NSString *)renderForVariableTagInContext:(GRMustacheVariableTagRenderingContext *)context
+{
+ // Render the "person.mustache" partial
+ return [context renderTemplateNamed:@"person" error:NULL];
+}
+
+@end
+```
+
+
+[up](introduction.md), [next](filters.md)
View
8 README.md
@@ -3,7 +3,7 @@ GRMustache
GRMustache is a production-ready implementation of [Mustache](http://mustache.github.com/) templates for MacOS Cocoa and iOS.
-**September 23th, 2012: GRMustache 5.2 is out.** [Release notes](GRMustache/blob/master/RELEASE_NOTES.md)
+**September 26th, 2012: GRMustache 5.3 is out.** [Release notes](GRMustache/blob/master/RELEASE_NOTES.md)
Don't miss a single release: follow [@GRMustache](http://twitter.com/GRMustache) on Twitter.
@@ -69,8 +69,8 @@ Rendering templates:
Advanced Mustache:
-- [section_helpers.md](GRMustache/blob/master/Guides/section_helpers.md): how to process the template canvas before it is rendered with Mustache "lambda sections".
-- [variable_helpers.md](GRMustache/blob/master/Guides/variable_helpers.md): how to perform rich rendering out of a simple `{{name}}` tag.
+- [section_tag_helpers.md](GRMustache/blob/master/Guides/section_tag_helpers.md): how to process the template canvas before it is rendered with Mustache "lambda sections".
+- [variable_tag_helpers.md](GRMustache/blob/master/Guides/variable_tag_helpers.md): how to perform rich rendering out of a simple `{{name}}` tag.
- [filters.md](GRMustache/blob/master/Guides/filters.md): how to process data before it is rendered with "filters".
- [delegate.md](GRMustache/blob/master/Guides/delegate.md): how to hook into template rendering.
@@ -102,7 +102,7 @@ FAQ
- **Q: How do I render partial templates whose name is only known at runtime?**
- A: Check [Guides/variable_helpers.md](GRMustache/blob/master/Guides/variable_helpers.md)
+ A: Check [Guides/variable_tag_helpers.md](GRMustache/blob/master/Guides/variable_tag_helpers.md)
- **Q: Does GRMustache provide any layout or template inheritance facility?**
View
49 RELEASE_NOTES.md
@@ -4,13 +4,60 @@ GRMustache Release Notes
You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark.
+## v5.3.0
+
+**API cleanup**
+
+The introduction of variable tag helpers in v5.1.0 introduced many confusing APIs. Those are still there, but deprecated.
+
+No new feature has been added, but semantics have been much improved. Many thanks to [@pierlo](https://github.com/pierlo) for his help.
+
+### Helpers API changes
+
+`GRMustacheVariableTagHelper` replaces `GRMustacheVariableHelper`. See [Guides/variable_tag_helpers.md](Guides/variable_tag_helpers.md).
+
+```objc
+@protocol GRMustacheVariableTagHelper<NSObject>
+@required
+- (NSString *)renderForVariableTagInContext:(GRMustacheVariableTagRenderingContext *)context;
+@end
+
+@interface GRMustacheVariableTagRenderingContext : NSObject
+- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+- (NSString *)renderTemplateNamed:(NSString *)name error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+@end
+```
+
+`GRMustacheSectionTagHelper` replaces `GRMustacheSectionHelper`. See [Guides/section_tag_helpers.md](Guides/section_tag_helpers.md).
+
+```objc
+@protocol GRMustacheSectionTagHelper<NSObject>
+@required
+- (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+@end
+
+@interface GRMustacheSectionTagRenderingContext: NSObject
+@property (nonatomic, readonly) NSString *innerTemplateString AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+- (NSString *)render AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+- (NSString *)renderTemplateString:(NSString *)string error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
+@end
+```
+
+### GRMustacheTemplateDelegate API changes
+
+In the `GRMustacheInterpretation` enumeration, `GRMustacheSectionTagInterpretation` replaces `GRMustacheInterpretationSection`, and `GRMustacheVariableTagInterpretation` replaces `GRMustacheInterpretationVariable`.
+
+### GRMustacheTemplate API changes
+
+`[GRMustacheTemplate renderObjectsFromArray:]` and `[GRMustacheTemplate renderObjectsFromArray:withFilters:]` replace `[GRMustacheTemplate renderObjectsInArray:]` and `[GRMustacheTemplate renderObjectsInArray:withFilters:]`.
+
## v5.2.0
**Overridable partials**
Inspired by [hogan.js](http://twitter.github.com/hogan.js/) and [spullara/mustache.java](https://github.com/spullara/mustache.java), GRMustache now supports "template inheritance". Precisely, your templates can embed as many partials as before, but now you can override portions of those partials.
-Overridable partials are documented as [Guides/templates.md](Guides/templates.md).
+Overridable partials are documented as [Guides/partials.md](Guides/partials.md).
The [layout](../../tree/master/Guides/sample_code/layout) sample code has been updated to take profit of overridable partials. There is not much left of it :-).
View
4 Reference/html/Classes/GRMustache.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -306,7 +306,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
4 Reference/html/Classes/GRMustacheFilter.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -232,7 +232,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
7 Reference/html/Classes/GRMustacheHelper.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -190,7 +190,8 @@ <h4 class="method-subtitle parameter-title">Return Value</h4>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v2.0</p>
+ <p>v2.0
+@deprecated v5.3</p>
</div>
@@ -224,7 +225,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
4 Reference/html/Classes/GRMustacheInvocation.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -307,7 +307,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
17 Reference/html/Classes/GRMustacheSection.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -139,9 +139,9 @@ <h2 class="subtitle subtitle-overview">Overview</h2>
<p>You will be provided with GRMustacheSection objects when implementing
mustache lambda sections with objects conforming to the
-<a href="../Classes/GRMustacheSectionHelper.html">GRMustacheSectionHelper</a> protocol.</p>
+deprecated <a href="../Classes/GRMustacheSectionHelper.html">GRMustacheSectionHelper</a> protocol.</p>
-<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/helpers.md">https://github.com/groue/GRMustache/blob/master/Guides/helpers.md</a></p>
+<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/section">https://github.com/groue/GRMustache/blob/master/Guides/section</a>_tag_helpers.md</p>
</div>
@@ -231,7 +231,8 @@ <h3 class="subsubtitle method-title">innerTemplateString</h3>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v2.0</p>
+ <p>v2.0
+@deprecated v5.3</p>
</div>
@@ -287,7 +288,8 @@ <h4 class="method-subtitle parameter-title">Return Value</h4>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v2.0</p>
+ <p>v2.0
+@deprecated v5.3</p>
</div>
@@ -350,7 +352,8 @@ <h4 class="method-subtitle parameter-title">Return Value</h4>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v4.3</p>
+ <p>v4.3
+@deprecated v5.3</p>
</div>
@@ -382,7 +385,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
9 Reference/html/Classes/GRMustacheSectionHelper.html
@@ -12,7 +12,7 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
@@ -121,7 +121,7 @@ <h2 class="subtitle subtitle-overview">Overview</h2>
<p>The GRMustacheSectionHelper class helps building mustache helpers without
writing a custom class that conforms to the GRMustacheSectionHelper protocol.</p>
-<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/helpers.md">https://github.com/groue/GRMustache/blob/master/Guides/helpers.md</a></p>
+<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/section">https://github.com/groue/GRMustache/blob/master/Guides/section</a>_tag_helpers.md</p>
</div>
@@ -198,7 +198,8 @@ <h4 class="method-subtitle parameter-title">Return Value</h4>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v2.0</p>
+ <p>v2.0
+@deprecated v5.3</p>
</div>
@@ -232,7 +233,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
58 ...tml/Classes/GRMustacheDynamicPartial.html → ...l/Classes/GRMustacheSectionTagHelper.html
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="html/html; charset=utf-8" />
- <title>GRMustacheDynamicPartial Class Reference</title>
+ <title>GRMustacheSectionTagHelper Class Reference</title>
<meta id="xcode-display" name="xcode-display" content="render"/>
<meta name="viewport" content="width=550" />
<link rel="stylesheet" type="text/css" href="../css/styles.css" media="all" />
@@ -12,12 +12,12 @@
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
- <h1><a id="libraryTitle" href="../index.html">GRMustache 5.2 </a></h1>
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
<a id="developerHome" href="../index.html">Gwendal Roué</a>
</div>
<div id="title" role="banner">
- <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
+ <h1 class="hideInXcode">GRMustacheSectionTagHelper Class Reference</h1>
</div>
<ul id="headerButtons" role="toolbar">
<li id="toc_button">
@@ -42,7 +42,7 @@ <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
<option value="class_methods">Class Methods</option>
- <option value="//api/name/dynamicPartialWithName:">&nbsp;&nbsp;&nbsp;&nbsp;+ dynamicPartialWithName:</option>
+ <option value="//api/name/helperWithBlock:">&nbsp;&nbsp;&nbsp;&nbsp;+ helperWithBlock:</option>
@@ -62,7 +62,7 @@ <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
<li role="treeitem" id="task_treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#tasks">Tasks</a></span><ul>
- <li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Creating Dynamic Partials">Creating Dynamic Partials</a></span></li>
+ <li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Creating Helpers">Creating Helpers</a></span></li>
</ul></li>
@@ -74,7 +74,7 @@ <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
<li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#class_methods">Class Methods</a></span><ul>
- <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/dynamicPartialWithName:">dynamicPartialWithName:</a></span></li>
+ <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/helperWithBlock:">helperWithBlock:</a></span></li>
</ul></li>
@@ -85,7 +85,7 @@ <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
</nav>
<article>
<div id="contents" class="isShowingTOC" role="main">
- <a title="GRMustacheDynamicPartial Class Reference" name="top"></a>
+ <a title="GRMustacheSectionTagHelper Class Reference" name="top"></a>
<div class="main-navigation navigation-top">
<ul>
<li><a href="../index.html">Index</a></li>
@@ -94,7 +94,7 @@ <h1 class="hideInXcode">GRMustacheDynamicPartial Class Reference</h1>
</div>
<div id="header">
<div class="section-header">
- <h1 class="title title-header">GRMustacheDynamicPartial Class Reference</h1>
+ <h1 class="title title-header">GRMustacheSectionTagHelper Class Reference</h1>
</div>
</div>
<div id="container">
@@ -105,10 +105,10 @@ <h1 class="title title-header">GRMustacheDynamicPartial Class Reference</h1>
<td class="specification-value">NSObject</td>
</tr><tr>
<td class="specification-title">Conforms to</td>
- <td class="specification-value"><a href="../Protocols/GRMustacheVariableHelper.html">GRMustacheVariableHelper</a></td>
+ <td class="specification-value"><a href="../Protocols/GRMustacheSectionTagHelper.html">GRMustacheSectionTagHelper</a></td>
</tr><tr>
<td class="specification-title">Declared in</td>
- <td class="specification-value">GRMustacheVariableHelper.h</td>
+ <td class="specification-value">GRMustacheSectionTagHelper.h</td>
</tr>
</tbody></table></div>
@@ -118,10 +118,10 @@ <h1 class="title title-header">GRMustacheDynamicPartial Class Reference</h1>
<div class="section section-overview">
<a title="Overview" name="overview"></a>
<h2 class="subtitle subtitle-overview">Overview</h2>
- <p>The GRMustacheDynamicPartial is a specific kind of <a href="../Classes/GRMustacheVariableHelper.html">GRMustacheVariableHelper</a>
-that, given a partial template name, renders this template.</p>
+ <p>The GRMustacheSectionTagHelper class helps building mustache helpers without
+writing a custom class that conforms to the GRMustacheSectionTagHelper protocol.</p>
-<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/helpers.md">https://github.com/groue/GRMustache/blob/master/Guides/helpers.md</a></p>
+<p><strong>Companion guide:</strong> <a href="https://github.com/groue/GRMustache/blob/master/Guides/section">https://github.com/groue/GRMustache/blob/master/Guides/section</a>_tag_helpers.md</p>
</div>
@@ -133,15 +133,15 @@ <h2 class="subtitle subtitle-overview">Overview</h2>
<h2 class="subtitle subtitle-tasks">Tasks</h2>
- <a title="Creating Dynamic Partials" name="task_Creating Dynamic Partials"></a>
+ <a title="Creating Helpers" name="task_Creating Helpers"></a>
-<h3 class="subsubtitle task-title">Creating Dynamic Partials</h3>
+<h3 class="subsubtitle task-title">Creating Helpers</h3>
<ul class="task-list">
<li>
<span class="tooltip">
- <code><a href="#//api/name/dynamicPartialWithName:">+&nbsp;dynamicPartialWithName:</a></code>
- <span class="tooltip"><p>Returns a GRMustacheDynamicPartial that renders a partial template named
-<em>name</em>.</p></span>
+ <code><a href="#//api/name/helperWithBlock:">+&nbsp;helperWithBlock:</a></code>
+ <span class="tooltip"><p>Returns a GRMustacheSectionTagHelper object that executes the provided block
+when rendering a Mustache section.</p></span>
</span>
@@ -161,28 +161,28 @@ <h3 class="subsubtitle task-title">Creating Dynamic Partials</h3>
<h2 class="subtitle subtitle-methods">Class Methods</h2>
<div class="section-method">
- <a name="//api/name/dynamicPartialWithName:" title="dynamicPartialWithName:"></a>
- <h3 class="subsubtitle method-title">dynamicPartialWithName:</h3>
+ <a name="//api/name/helperWithBlock:" title="helperWithBlock:"></a>
+ <h3 class="subsubtitle method-title">helperWithBlock:</h3>
<div class="method-subsection brief-description">
- <p>Returns a GRMustacheDynamicPartial that renders a partial template named
-<em>name</em>.</p>
+ <p>Returns a GRMustacheSectionTagHelper object that executes the provided block
+when rendering a Mustache section.</p>
</div>
- <div class="method-subsection method-declaration"><code>+ (id)dynamicPartialWithName:(NSString *)<em>name</em></code></div>
+ <div class="method-subsection method-declaration"><code>+ (id)helperWithBlock:(NSString *( ^ ) ( GRMustacheSectionTagRenderingContext *context ))<em>block</em></code></div>
<div class="method-subsection arguments-section parameters">
<h4 class="method-subtitle parameter-title">Parameters</h4>
<dl class="argument-def parameter-def">
- <dt><em>name</em></dt>
- <dd><p>A template name</p></dd>
+ <dt><em>block</em></dt>
+ <dd><p>The block that renders a section.</p></dd>
</dl>
</div>
@@ -191,14 +191,14 @@ <h4 class="method-subtitle parameter-title">Parameters</h4>
<div class="method-subsection return">
<h4 class="method-subtitle parameter-title">Return Value</h4>
- <p>a GRMustacheDynamicPartial</p>
+ <p>a GRMustacheSectionTagHelper object.</p>
</div>
<div class="method-subsection availability">
<h4 class="method-subtitle parameter-title">Availability</h4>
- <p>v5.1</p>
+ <p>v5.3</p>
</div>
@@ -211,7 +211,7 @@ <h4 class="method-subtitle parameter-title">Availability</h4>
<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
- <code class="declared-in-ref">GRMustacheVariableHelper.h</code><br />
+ <code class="declared-in-ref">GRMustacheSectionTagHelper.h</code><br />
</div>
@@ -232,7 +232,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
- <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-23)</span><br />
+ <p><span class="copyright">&copy; 2012 Gwendal Roué. All rights reserved. (Last updated: 2012-09-26)</span><br />
<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.0.6 (build 789)</a>.</span></p>
View
482 Reference/html/Classes/GRMustacheSectionTagRenderingContext.html
@@ -0,0 +1,482 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="html/html; charset=utf-8" />
+ <title>GRMustacheSectionTagRenderingContext Class Reference</title>
+ <meta id="xcode-display" name="xcode-display" content="render"/>
+ <meta name="viewport" content="width=550" />
+ <link rel="stylesheet" type="text/css" href="../css/styles.css" media="all" />
+ <link rel="stylesheet" type="text/css" media="print" href="../css/stylesPrint.css" />
+ <meta name="generator" content="appledoc 2.0.6 (build 789)" />
+ </head>
+ <body>
+ <header id="top_header">
+ <div id="library" class="hideInXcode">
+ <h1><a id="libraryTitle" href="../index.html">GRMustache 5.3 </a></h1>
+ <a id="developerHome" href="../index.html">Gwendal Roué</a>
+ </div>
+
+ <div id="title" role="banner">
+ <h1 class="hideInXcode">GRMustacheSectionTagRenderingContext Class Reference</h1>
+ </div>
+ <ul id="headerButtons" role="toolbar">
+ <li id="toc_button">
+ <button aria-label="Show Table of Contents" role="checkbox" class="open" id="table_of_contents"><span class="disclosure"></span>Table of Contents</button>
+ </li>
+ <li id="jumpto_button" role="navigation">
+ <select id="jumpTo">
+ <option value="top">Jump To&#133;</option>
+
+ <option value="overview">Overview</option>
+
+
+
+
+ <option value="tasks">Tasks</option>
+
+
+
+
+
+ <option value="properties">Properties</option>
+
+ <option value="//api/name/innerTemplateString">&nbsp;&nbsp;&nbsp;&nbsp;innerTemplateString</option>
+
+
+
+
+
+