Class Mustache::Template
In: lib/mustache/template.rb
Parent: Object

A Template represents a Mustache template. It compiles and caches a raw string template into something usable.

The idea is this: when handed a Mustache template, convert it into a Ruby string by transforming Mustache tags into interpolated Ruby.

You shouldn‘t use this class directly, instead:

>> Mustache.render(template, hash)

Methods

compile   new   render   to_s   tokens  

Attributes

source  [R] 

Public Class methods

Expects a Mustache template as a string along with a template path, which it uses to find partials.

Public Instance methods

Does the dirty work of transforming a Mustache template into an interpolation-friendly Ruby string.

Renders the `@source` Mustache template using the given `context`, which should be a simple hash keyed with symbols.

The first time a template is rendered, this method is overriden and from then on it is "compiled". Subsequent calls will skip the compilation step and run the Ruby version of the template directly.

to_s(src = @source)

Alias for compile

Returns an array of tokens for a given template.

[Validate]