Class: Wraith.Template
Defined in: | src/template.coffee |
Overview
The Wraith Template object is responsible for storing a template string, generating a template function and interpolating the data to generate a view off a given set of data.
Note: Based on John Resig's microtemplating function(s).
Class Method Summary
- + (void) escapeRegExp(string) Borrowed from Underscores templates
- + (void) interpolate(model, tokens) Bound Takes a given token array and seeks out its value in the given model.
- + (void) interpolateClass(model, tokens) Bound Takes a given token array and seeks out its value in the given model.
Instance Method Summary
- - (void) constructor(template) Constructor Constructor
- - (void) compile(data) Compiles a template with a ERB style markup.
Class Method Details
+ (void) escapeRegExp(string)
Borrowed from Underscores templates
+ (void) interpolate(model, tokens) (bound)
Takes a given token array and seeks out its value in the given model. It currently assumes that a model is a Wraith.Model object.
@returns [Object|String|Boolean] The results of the token search
+ (void) interpolateClass(model, tokens) (bound)
Takes a given token array and seeks out its value in the given model. It currently assumes that a model is a Wraith.Model object.
@returns [Object|String|Boolean] The results of the token search
Constructor Details
- (void) constructor(template)
Constructor
Instance Method Details
- (void) compile(data)
Compiles a template with a ERB style markup. Note: Override this if you want to use a different template system.
NOTE: JavaScript templating a-la ERB, pilfered from John Resig's Secrets of the JavaScript Ninja, page 83. Single-quote fix from Rick Strahl. With alterations for arbitrary delimiters, and to preserve whitespace.