Browse files

v5.4.2

  • Loading branch information...
1 parent b87574f commit cc63d535a61600a9c878b8c8f7d4c831b38464d0 @groue committed Sep 29, 2012
View
50 Guides/filters.md
@@ -25,6 +25,8 @@ You apply a filter just like calling a function, with parentheses:
For brevity's sake, closing section tags can be empty: `{{^ isEmpty(people) }}...{{/}}` is valid.
+- Filters can return filters: `{{ dateFormat(format)(date) }}`.
+
Standard filters library
------------------------
@@ -133,6 +135,54 @@ id filters = @{
```
+Filters that return filters
+---------------------------
+
+Some of you may like defining "meta-filters". No problem:
+
+template.mustache:
+
+ {{#object1}}
+ {{ dateFormat(format)(date) }}
+ {{/object1}}
+ {{#object2}}
+ {{ dateFormat(format)(date) }}
+ {{/object2}}
+
+```objc
+id filters = @{
+ @"dateFormat": [GRMustacheFilter filterWithBlock:^id(id format) {
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] new];
+ dateFormatter.dateFormat = [format description]; // force string coercion
+ return [GRMustacheFilter filterWithBlock:^id(id date) {
+ return [dateFormatter stringFromDate:date];
+ }];
+ }]
+};
+
+id data = @{
+ @"object1": @{
+ @"format": @"yyyy-MM-dd 'at' HH:mm",
+ @"date": [NSDate date];
+ }
+ @"object2": @{
+ @"format": @"yyyy-MM-dd",
+ @"date": [NSDate date];
+ }
+}
+
+NSString *rendering = [GRMustacheTemplate renderObject:data
+ withFilters:filters
+ fromResource:@"template"
+ error:NULL];
+```
+
+Rendering:
+
+ 2012-09-29 at 12:54
+ 2012-09-29
+
+
Filters exceptions
------------------
View
2 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 29th, 2012: GRMustache 5.4.1 is out.** [Release notes](GRMustache/blob/master/RELEASE_NOTES.md)
+**September 29th, 2012: GRMustache 5.4.2 is out.** [Release notes](GRMustache/blob/master/RELEASE_NOTES.md)
Don't miss a single release: follow [@GRMustache](http://twitter.com/GRMustache) on Twitter.
View
4 RELEASE_NOTES.md
@@ -4,6 +4,10 @@ GRMustache Release Notes
You can compare the performances of GRMustache versions at https://github.com/groue/GRMustacheBenchmark.
+## v5.4.2
+
+Until this version, filters could not return filters. This useless inconsistency is considered a bug, and has been fixed. Check [Guides/filters.md](Guides/filters.md).
+
## v5.4.1
Fix some corner cases in the handling of [overridable partials](Guides/partials.md), should your templates include conflicting overriding sections. Basically, the last one wins:
View
2 include/GRMustacheVersion.h
@@ -40,5 +40,5 @@
*
* @since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 1
+#define GRMUSTACHE_PATCH_VERSION 2
View
BIN lib/libGRMustache5-MacOS.a
Binary file not shown.
View
BIN lib/libGRMustache5-iOS.a
Binary file not shown.
View
2 src/classes/GRMustacheVersion.h
@@ -40,5 +40,5 @@
*
* @since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 1
+#define GRMUSTACHE_PATCH_VERSION 2

0 comments on commit cc63d53

Please sign in to comment.