class Mustache

Mustache is the base class from which your Mustache subclasses should inherit (though it can be used on its own).

The typical Mustache workflow is as follows:

You can skip the instantiation by calling ‘Stats.render` directly.

While Mustache will do its best to load and render a template for you, this process is completely customizable using a few options.

All settings can be overriden at the class level.

For example, going with the above example, we can use ‘Stats.template_path = “/usr/local/templates”` to specify the path Mustache uses to find templates.

Here are the available options:

The ‘template_path` setting determines the path Mustache uses when looking for a template. By default it is “.” Setting it to /usr/local/templates, for example, means (given all other settings are default) a Mustache subclass `Stats` will try to load /usr/local/templates/stats.mustache

The ‘template_extension` is the extension Mustache uses when looking for template files. By default it is “mustache”

You can tell Mustache exactly which template to use with this setting. It can be a relative or absolute path.

Sometimes you want Mustache to render a string, not a file. In those cases you may set the ‘template` setting. For example:

>> Mustache.render("Hello {{planet}}", :planet => "World!")
=> "Hello World!"

The ‘template` setting is also available on instances.

view = Mustache.new
view.template = "Hi, {{person}}!"
view[:person] = 'Mom'
view.render # => Hi, mom!

To make life easy on those developing Mustache plugins for web frameworks or other libraries, Mustache will attempt to load view classes (i.e. Mustache subclasses) using the ‘view_class` class method. The `view_namespace` tells Mustache under which constant view classes live. By default it is `Object`.

Similar to ‘template_path`, the `view_path` option tells Mustache where to look for files containing view classes when using the `view_class` method.

Settings which can be configured for all view classes, a single view class, or a single Mustache instance.