Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

165 lines (95 sloc) 7.426 kb

GRMustache

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

October 21th, 2012: GRMustache 5.5.1 is out. Release notes

Don't miss a single release: follow @GRMustache on Twitter.

How To

1. Download and add to your Xcode project

$ git clone https://github.com/groue/GRMustache.git
  • For MacOS development, add include/GRMustache.h and lib/libGRMustache5-MacOS.a to your project.
  • For iOS development, add include/GRMustache.h and lib/libGRMustache5-iOS.a to your project.

Alternatively, you may use CocoaPods: append pod 'GRMustache', '~> 5.5' to your Podfile.

GRMustache targets MacOS down to 10.6 Snow Leopard, iOS down to version 4.3, and only depends on the Foundation framework.

armv6 architecture: The last GRMustache static library that embeds the armv6 slice is GRMustache 5.0.1. You now have to compile GRMustache yourself, or to use CocoaPods.

2. Start rendering templates

#import "GRMustache.h"

// Renders "Hello Arthur!"
NSString *rendering = [GRMustacheTemplate renderObject:[Person personWithName:@"Arthur"]
                                            fromString:@"Hello {{name}}!"
                                                 error:NULL];

// Renders a document from the `Profile.mustache` resource
NSString *rendering = [GRMustacheTemplate renderObject:[Person personWithName:@"Arthur"]
                                          fromResource:@"Profile"
                                                bundle:nil
                                                 error:NULL];

Documentation

Mustache syntax

Guides

Introduction:

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

Loading templates:

Rendering templates:

Advanced Mustache:

  • section_tag_helpers.md: how to process the template canvas before it is rendered with Mustache "lambda sections".
  • variable_tag_helpers.md: how to perform rich rendering out of a simple {{name}} tag.
  • filters.md: how to process data before it is rendered with "filters".
  • delegate.md: how to hook into template rendering.
  • proxies.md: how to extend the behavior of regular objects, and write robust and reusable filters and helpers.

Sample code

Reference

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

Internals

  • forking.md: the forking guide tells you everything about GRMustache organization.

FAQ

What other people say

@JeffSchilling:

I'm loving grmustache

@basilshkara:

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

@guiheneuf:

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

@orj:

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

Contribution wish-list

I wish somebody would review my non-native English, and clean up the guides, if you ask.

Forking

Please fork. You'll learn useful information in Guides/forking.md.

License

Released under the MIT License.

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