Behance Hogan Compiler
This Browser / Node.js library is a helper for loading mustache templates via Hogan.js.
Features
- caching & asynchronous loading
- retrieval and resolution of partials
- retrieve the files any way you like via the driver (e.g, XHR in the browser and fs in Node.js)
Usage
const hoganCompiler = ; // Bring Your Own Driverconst fsDriver = ;const templatesPath = '/tmp'; const compiler = hoganCompiler; // When using `options.isCached`, you may want to populate the cache before making `.compile()` callscompiler; // provide just the name, no need for the template dir or the extensioncompiler;
Create Arguments:
driver
- will be used to read files. All methods must return a Promise. Seesrc/drivers/fs
for an example.templatesPath
- absolute path to the templatesoptions.extension
- defaults tomustache
(e.g.,template.mustache
)options.isCached
- cache compiled templates in the created instance
HoganCompilerOptions:
asString
- return the compiled template as a string. This feature is used by hulk to produce strings containing pre-compiled templates.sectionTags
- allow custom tags that require opening and closing tags, and treat them as though they were section tags.delimiters
- A string that overrides the default delimiters. Example: "<% %>"disableLambda
- isables the higher-order sections / lambda-replace features of Mustache.
For more details see Hogan Compilation options.