UNPKG

engine-lodash

Version:

Lo-Dash engine, consolidate.js style but with enhancements. Works with Assemble, express.js, engine-cache or any application that follows consolidate.js conventions.

103 lines (67 loc) 3.68 kB
# engine-lodash [![NPM version](https://badge.fury.io/js/engine-lodash.svg)](http://badge.fury.io/js/engine-lodash) [![Build Status](https://travis-ci.org/jonschlinkert/engine-lodash.svg)](https://travis-ci.org/jonschlinkert/engine-lodash) > Lo-Dash engine, consolidate.js style but with enhancements. Works with Assemble, express.js, engine-cache or any application that follows consolidate.js conventions. Install with [npm](https://www.npmjs.com/) ```sh $ npm i engine-lodash --save ``` ## Usage ```js var lodash = require('engine-lodash'); ``` ## API ### [.render](index.js#L56) Lodash string support. Render the given `str` and invoke the callback `callback(err, str)`. **Params** * `str` **{String}** * `options` **{Object|Function}**: or callback. * `callback` **{Function}** **Example** ```js var engine = require('engine-lodash'); engine.render('<%= name %>', {name: 'Jon'}, function (err, content) { console.log(content); //=> 'Jon' }); ``` ### [.renderSync](index.js#L140) Render Lo-Dash or underscore templates synchronously. **Params** * `str` **{Object}**: The string to render. * `options` **{Object}**: Object of options. * `returns` **{String}**: Rendered string. **Example** ```js var engine = require('engine-lodash'); engine.renderSync('<%= name %>', {name: 'Halle'}); //=> 'Halle' ``` ### [.renderFile](index.js#L171) Lodash 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-lodash'); 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) + [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) ## Authors **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) **Brian Woodward** * [github/doowb](https://github.com/doowb) * [twitter/doowb](http://twitter.com/doowb) ## License Copyright © 2014-2015 https://github.com/jonschlinkert Released under the MIT license. *** _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 21, 2015._