Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
212 lines (121 sloc) 8.36 KB


GRMustache is a flexible and production-ready implementation of Mustache templates for MacOS Cocoa and iOS.

GRMustache targets iOS down to version 4.3, MacOS down to 10.6 Snow Leopard (with or without garbage collection), and only depends on the Foundation framework.

August 10, 2013: GRMustache 6.8.2 is out. Release notes

Get release announcements and usage tips: follow @GRMustache on Twitter.

How To

1. Setup your Xcode project

You have three options, from the simplest to the hairiest:

2. Start rendering templates

#import "GRMustache.h"

// Renders "Hello Arthur!"
NSString *rendering = [GRMustacheTemplate renderObject:@{ @"name": @"Arthur" }
                                            fromString:@"Hello {{name}}!"

// Renders a document from the `Profile.mustache` resource
GRMustacheTemplate *template = [GRMustacheTemplate templateFromResource:@"Profile" bundle:nil error:NULL];
NSString *rendering = [template renderObject:self.currentUser error:NULL];

GRMustachio by Jonathan Mitchell is "A super simple, interactive GRMustache based application". It can help you design and test your templates.


Mustache syntax


  • Reference: the GRMustache reference, automatically generated from inline documentation, for fun and profit, by appledoc.



  • Introduction: a tour of the library features, and most common use cases.




Mustache, and beyond:

  • Compatibility: compatibility with other Mustache implementations, in details.

Sample code

Check the FAQ right below.


  • Q: I get "unrecognized selector sent to instance" errors.

    A: Check that you have added the -ObjC option in the "Other Linker Flags" of your target (how to).

  • Q: Is it possible to render array indexes? Customize first and last elements? Distinguish odd and even items, play fizzbuzz?

    A: Yes, yes, and yes

  • Q: Is it possible to format numbers and dates?

    A: Yes. Use NSNumberFormatter and NSDateFormatter.

  • Q: Is it possible to pluralize/singularize strings?

    A: Yes. You have some sample code in issue #50. You may check @mattt's InflectorKit for actual inflection methods.

  • Q: Is it possible to write Handlebars-like helpers?

    A: Yes

  • Q: Is it possible to localize templates?

    A: Yes

  • Q: Is it possible to embed partial templates whose name is only known at runtime?

    A: Yes

  • Q: Does GRMustache provide any layout or template inheritance facility?

    A: Yes

  • Q: Is it possible to render a default value for missing keys?

    A: Yes.

  • Q: Is it possible to disable HTML escaping?

    A: Yes

  • Q: What is this NSUndefinedKeyException stuff?

    A: When GRMustache has to try several objects until it finds the one that provides a {{key}}, several NSUndefinedKeyException may be raised and caught. It's likely that you wish Xcode would stop breaking on those exceptions: see the Runtime Guide.

  • Q: Why does GRMustache need JRSwizzle?

    A: GRMustache does not need it, and does not swizzle anything unless you explicitly ask for it. [GRMustache preventNSUndefinedKeyExceptionAttack] swizzles NSObject's valueForUndefinedKey: in order to prevent NSUndefinedKeyException during template rendering.

    You will debug your application without Xcode's exception breakpoint disturbing you. You may even improve rendering performances. See the Runtime Guide.

What other people say


I'm loving grmustache


Oh man GRMustache saved my ass once again. Awesome lib.


GRMustache filters extension saved us from great escaping PITAs. Thanks @groue.


Thank fucking christ for decent iOS developers who ship .lib files in their Github repos. #GRMustache


@issya should see the HTML template I built, pretty wicked. GRMustache is the best.


Using GRMustache (Cocoa) for template processing. Looks like a top quality library. Good developer and good units tests. Get it on GitHub.


okay GRMustache is the fucking daddy


GRMustache is teh awesome. Nice to find an open-source library that is more pleasant to use than expected.

Who's using GRMustache

  • tomaz/appledoc: Objective-c code Apple style documentation set generator
  • mapbox/mapbox-ios-sdk: MapBox iOS SDK, an open source alternative to MapKit
  • CarterA/Tribo: Extremely fast static site generator written in Objective-C
  • AutoLib uses GRMustache and spullara/ for rendering an identical set of Mustache templates on iOS and Android.
  • CinéObs uses GRMustache for RSS feeds rendering
  • Fotopedia, the first collaborative photo encyclopedia
  • FunGolf GPS, a golf app with 3D maps
  • KosmicTask, an integrated scripting environment for OS X that supports more than 20 scripting languages.
  • Servus can turn any file on your computer into a branded download page hosted on Dropbox.

Do you use GRMustache? Tweet me your link.

Contribution wish-list

Please look for an open issue that smiles at you!

... And I wish somebody would review the non-native English of the documentation and guides.


Please fork. You'll learn useful information in the Forking Guide.


Released under the MIT License.

Jump to Line
Something went wrong with that request. Please try again.