Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation lacks of precision in filter definition #59

Closed
spacreau opened this issue Sep 6, 2013 · 3 comments
Closed

Documentation lacks of precision in filter definition #59

spacreau opened this issue Sep 6, 2013 · 3 comments

Comments

@spacreau
Copy link

spacreau commented Sep 6, 2013

Need to render object with filters defined separately with the method :

  • (NSString *)renderObject:(id)object withFilters:(id)filters ;

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

@groue
Copy link
Owner

groue commented Sep 7, 2013

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];

@groue
Copy link
Owner

groue commented Sep 7, 2013

I do not understand the title of the issue: "Documentation lacks of precision in filter definition" ?

@groue
Copy link
Owner

groue commented Sep 8, 2013

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.

@groue groue closed this as completed Sep 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants