groue / GRMustache

Flexible and production-ready Mustache templates for MacOS Cocoa and iOS
http://mustache.github.com/
MIT License
1.44k stars 190 forks source link

Filters doesn't work on versions prior to 5.4.4 #28

Closed artem-alexandrov closed 11 years ago

artem-alexandrov commented 11 years ago

On the versions between 5.4.4 and 4.3.0 any filter in template string generates error "Error Domain=GRMustacheErrorDomain Code=0 "Parse error at line 1: Invalid expression"" on processing attempt.

I need working GRMustache with filters and with armv6 support.

I've just built last version for armv6, but you need to figure what the problem is.

groue commented 11 years ago

Could you please provide some sample code?

artem-alexandrov commented 11 years ago

Of course, here it is:

NSString *theTemplate = @"{{ count(array) }}";

NSError *error = nil;

GRMustacheTemplate *parsedTemplate = [GRMustacheTemplate templateFromString:theTemplate error:&error];

// error is not nil here!!

NSArray array = [NSArray arrayWithObjects:@"str1", @"str2", @"str3", nil]; NSString arrayDataObjectName = @"array"; NSDictionary *templateVariables = [NSDictionary dictionaryWithObject:array forKey:arrayDataObjectName];

NSString *processedTemplate = [parsedTemplate renderObjectsInArray:[NSArray arrayWithObjects:templateVariables, nil] withFilters:filters];

groue commented 11 years ago

OK. Your code looks legit.

I don't know which version of GRMustache you are using, but it is likely that it is an old version.

I advise you to update to the latest version, or to read the Guide/filters.md that ships with your version. It's likely that it tells that the {{%FILTERS}} pragma tag should be prepended to the beginning of your templates.

Tell me if it works.

artem-alexandrov commented 11 years ago

Yeah.. it works.. I didn't realized that I need to read documentation from the version I've downloaded and not the last one. Thanks for help!

groue commented 11 years ago

You're welcome! I close the issue. Please reopen, or open a new one, if something else is wrong. Happy GRMustache!