GRMustache is an implementation of Mustache templates for MacOS Cocoa and iOS.
It ships with built-in goodies and extensibility hooks that let you avoid the strict minimalism of the genuine Mustache language when you need it.
September 13, 2014: GRMustache 7.3.0 is out. Release notes
Get release announcements and usage tips: follow @GRMustache on Twitter.
GRMustache targets iOS down to version 4.3, MacOS down to 10.6 Snow Leopard (without garbage collection), and only depends on the Foundation framework.
You can use GRMustache from Swift. However, you can only render Objective-C objects.
You have three options, from the simplest to the hairiest:
#import "GRMustache.h"
One-liners:
// Renders "Hello Arthur!"
NSString *rendering = [GRMustacheTemplate renderObject:@{ @"name": @"Arthur" } fromString:@"Hello {{name}}!" error:NULL];
// Renders the `Profile.mustache` resource of the main bundle
NSString *rendering = [GRMustacheTemplate renderObject:user fromResource:@"Profile" bundle:nil error:NULL];
Reuse templates in order to avoid parsing the same template several times:
GRMustacheTemplate *template = [GRMustacheTemplate templateFromResource:@"Profile" bundle:nil error:nil];
rendering = [template renderObject:arthur error:NULL];
rendering = [template renderObject:barbara error:NULL];
rendering = ...
If you don't know Mustache, start here: http://mustache.github.io/mustache.5.html
- Guides: a guided tour of GRMustache
- Reference: all classes & protocols
- Troubleshooting
- FAQ
Released under the MIT License.