engine-base
Default engine for Template.
Install
Install with npm
$ npm i engine-base --save
Usage
var engine = require('engine-base');
API
Return a compiled function from the given template string
and options
.
Params
str
{String}: Template string to compile.options
{Object}: Options or settings to pass to basereturns
{Function}
Example
var engine = require('engine-base');
var fn = engine.compileSync('<%= name %>');
console.log(fn({name: 'Halle'}));
Return a compiled function from the given template string
and options
can callback
Params
str
{String}: Template string to compile.options
{Object}: Options or settings to pass to engine.cb
{Function}: Callback function
Example
var engine = require('engine-base');
engine.compile('<%= name %>', function (err, fn) {
console.log(fn({name: 'Halle'}));
});
Render templates synchronously.
Params
str
{Object}: The string to render.options
{Object}: Object of options.returns
{String}: Rendered string.
Example
var engine = require('engine-base');
engine.renderSync('<%= name %>', {name: 'Halle'});
String support. Render the given str
and invoke the callback callback(err, str)
.
Params
str
{String}locals
{Object|Function}: or callback.callback
{Function}
Example
var engine = require('engine-base');
engine.render('<%= name %>', {name: 'Jon'}, function (err, content) {
console.log(content);
});
File support. Render a file at the given filepath
and callback callback(err, str)
.
Params
path
{String}options
{Object|Function}: or callback function.callback
{Function}
Example
var engine = require('engine-base');
engine.renderFile('foo/bar/baz.tmpl', {name: 'Halle'});
Related projects
- engine-cache: express.js inspired template-engine manager. | homepage
- engine-handlebars: Handlebars engine, consolidate.js style but with enhancements. This works with Assemble, express.js, engine-cache or any… more | homepage
- engine-less: Consolidate-style engine for rendering .less files. | homepage
- engine-lodash: Lo-Dash engine, consolidate.js style but with enhancements. Works with Assemble, express.js, engine-cache or any application… more | homepage
- helper-cache: Easily register and get helper functions to be passed to any template engine or node.js… more | homepage
- template: Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… more | homepage
- template-helpers: Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… more | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on September 08, 2015.