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

Make template extension configurable #77

Closed apauly closed 10 years ago

apauly commented 10 years ago

It would be great if the default GRMustacheDefaultExtension would be configurable. We'd like to use "html.mustache" as the extension. We share our mustache templates with other implementations so it is nontrivial to change the filenames to match the given "mustache" extension.

groue commented 10 years ago

Hi.

The GRMustacheTemplateRepository class is your friend.

Pick one of the factory methods templateRepositoryWithDirectory:templateExtension:encoding:, templateRepositoryWithBaseURL:templateExtension:encoding: or templateRepositoryWithBundle:templateExtension:encoding:.

Then, load templates with [repo templateNamed:error:].

Wrapping all this up, this would give something like:

GRMustacheTemplateRepository *repo = [GRMustacheTemplateRepository templateRepositoryWith...];
GRMustacheTemplate *template = [repo templateNamed:...];
NSString *rendering = [template renderObject:... error:...];
apauly commented 10 years ago

Thanks, I didn't notice those methods. Works great!

groue commented 10 years ago

You're welcome :smile: