API Error - thegrandpoobah/mustache.js GitHub Wiki
API: Mustache.Error
Description
The Mustache.Error field is a class type which matches the type of the Error-derived object thrown by the Mustache interpreter when an error is encountered in the Mustache mark-up file(s). Developers will typically not instantiate this type directly, but rather use it in an exception handling try/catch block.
Layout
- name: string (always equivalent to 'MustacheError')
- message: A developer friendly message about the error that was encountered
- line: The line number the error was encountered on. NOTE that this field is not always present
- character: The character number the error was encountered on. NOTE that this field is not always present
- partial: The partial the error was encountered on. NOTE that this field is only available if the error was encountered in a partial or a higher order section. When triggered from a higher order section, the partial name is mangled and essentially random, so it should not be depended on.
Usage Example
try {
Mustache.to_html('{{#no_closing_tag}}This Section has no closing tag', { no_closing_tag: true });
} catch (e) {
if (e instanceof Mustache.Error) {
// A Mustache error occured
}
}