# engine-base [![NPM version](https://badge.fury.io/js/engine-base.svg)](http://badge.fury.io/js/engine-base) > Default engine for Template. ## Install Install with [npm](https://www.npmjs.com/) ```sh $ npm i engine-base --save ``` ## Usage ```js var engine = require('engine-base'); ``` ## API ### [compileSync](index.js#L44) 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 base * `returns` **{Function}** **Example** ```js var engine = require('engine-base'); var fn = engine.compileSync('<%= name %>'); console.log(fn({name: 'Halle'})); //=> 'Halle' ``` ### [compile](index.js#L84) 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** ```js var engine = require('engine-base'); engine.compile('<%= name %>', function (err, fn) { console.log(fn({name: 'Halle'})); //=> 'Halle' }); ``` ### [renderSync](index.js#L113) Render templates synchronously. **Params** * `str` **{Object}**: The string to render. * `options` **{Object}**: Object of options. * `returns` **{String}**: Rendered string. **Example** ```js var engine = require('engine-base'); engine.renderSync('<%= name %>', {name: 'Halle'}); //=> 'Halle' ``` ### [render](index.js#L162) String support. Render the given `str` and invoke the callback `callback(err, str)`. **Params** * `str` **{String}** * `locals` **{Object|Function}**: or callback. * `callback` **{Function}** **Example** ```js var engine = require('engine-base'); engine.render('<%= name %>', {name: 'Jon'}, function (err, content) { console.log(content); //=> 'Jon' }); ``` ### [renderFile](index.js#L190) 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** ```js var engine = require('engine-base'); engine.renderFile('foo/bar/baz.tmpl', {name: 'Halle'}); //=> 'Halle' ``` ## Related projects * [engine-cache](https://www.npmjs.com/package/engine-cache): express.js inspired template-engine manager. | [homepage](https://github.com/jonschlinkert/engine-cache) * [engine-handlebars](https://www.npmjs.com/package/engine-handlebars): Handlebars engine, consolidate.js style but with enhancements. This works with Assemble, express.js, engine-cache or any… [more](https://www.npmjs.com/package/engine-handlebars) | [homepage](https://github.com/jonschlinkert/engine-handlebars) * [engine-less](https://www.npmjs.com/package/engine-less): Consolidate-style engine for rendering .less files. | [homepage](https://github.com/jonschlinkert/engine-less) * [engine-lodash](https://www.npmjs.com/package/engine-lodash): Lo-Dash engine, consolidate.js style but with enhancements. Works with Assemble, express.js, engine-cache or any application… [more](https://www.npmjs.com/package/engine-lodash) | [homepage](https://github.com/jonschlinkert/engine-lodash) * [helper-cache](https://www.npmjs.com/package/helper-cache): Easily register and get helper functions to be passed to any template engine or node.js… [more](https://www.npmjs.com/package/helper-cache) | [homepage](https://github.com/jonschlinkert/helper-cache) * [template](https://www.npmjs.com/package/template): Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… [more](https://www.npmjs.com/package/template) | [homepage](https://github.com/jonschlinkert/template) * [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://www.npmjs.com/package/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers) ## Running tests Install dev dependencies: ```sh $ npm i -d && npm test ``` ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/engine-base/issues/new). ## Author **Jon Schlinkert** + [github/jonschlinkert](https://github.com/jonschlinkert) + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright © 2015 Jon Schlinkert Released under the MIT license. *** _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 08, 2015._