Mustache is a new templating library from Chris Wanstrath (a.k.a. defunkt of GitHub fame) that provides a way to render views in your chosen Ruby web framework. Influenced by ctemplate, Mustache helps to keep your MVC layers separate by actively preventing the inclusion of application logic in your views.
With Mustache, the typical view layer is split up into two sub-layers: a Ruby Class-based "view" and an HTML "template", so you can concentrate on crafting your HTML without polluting it with embedded Ruby logic. This separation also makes it easier to test your view-code.
Amusingly, the name of the project comes from the way that you insert references to the view class into the template. Tags are denoted by double curly braces, or "mustaches". e.g. {{name}}.
In their simplest form, tags are just calls to methods on your Ruby view class. But they can also take more complex forms such as block definitions, calls to partials or helpers (from modules included into your view class).
There are more examples and documentation in the GitHub project, but here's a canonical usage example from the README:
View Logic:class Simple Template:
Hello {{name}}
You have just won ${{value}}!
{{#in_ca}}
Well, ${{taxed_value}}, after taxes.
{{/in_ca}}
At the moment, only Sinatra support is provided "out of the box", but it should be fairly easy to integrate with other Ruby frameworks.
InstallationMustache is available from Gemcutter or Rip. Install in one of two ways:
$ gem install mustache $ rip install git://github.com/defunkt/mustache.git
[ad] Codebase is a fast & reliable git, mercurial & subversion hosting service with complete project management built-in - ticketing, milestones, wikis & time tracking - all under one roof. Click here to try it - free.