Closed spacreau closed 11 years ago
Hi, @spacreau
If you really need to provide data and filters in separate containers, here is a way to do it:
// One container for data...
id data = @{@"alert": @{ @"label": @"label.screen.reporting.content.label.alerts", @"allalerts": allalerts, } };
// A second container for filters (NSDateFormatter is already a filter since v6.4):
id filters = @{@"dateFormat" : self.dateFormatter };
// Rendering
NSString *rendering = [template renderObjectsFromArray:@[filters, data] error:NULL];
I do not understand the title of the issue: "Documentation lacks of precision in filter definition" ?
The more I think of it, the more I believe you are using an old version of GRMustache. The documentation for it is in the distribution itself (check the Guides folder). This website shows the documentation for the latest version of the library. If this does not answer your question, feel free to reopen this issue.
Need to render object with filters defined separately with the method :
like this
GRMustacheTemplate template = [GRMustacheTemplate templateFromResource:@"reportTemplate" bundle:nil error:NULL]; NSString rendering = [template renderObject:@{@"alert": @{ @"label": @"label.screen.reporting.content.label.alerts", @"allalerts": allalerts, } } withFilters:@{@"dateFormat" : [GRMustacheFilter filterWithBlock:^id(id object) { return [self.dateFormatter stringFromDate:object];}] } ];
{{ dateFormat(aircraftGPSPoint.timestamp) }}
else I never manage to render object with a filter