Go to file
2018-05-10 16:27:32 +02:00
.npmignore Initial commit. 2014-12-15 15:48:11 +01:00
index.js Used underscore only in generated template 2017-03-16 14:11:52 +01:00
LICENSE Initial commit. 2014-12-15 15:48:11 +01:00
package.json 0.2.2 2018-05-10 16:27:32 +02:00
README.md Fix typo 2018-05-10 16:15:04 +02:00

Lodash template for webpack

Lodash template loader for webpack. Uses _.template function to compile templates.

Installation

npm install tpl-loader

Usage

Documentation: Using loaders

var template = require("tpl!./file.html");
// => returns the template function compiled with underscore (lodash) templating engine.

// And then use it somewhere in your code
template(data) // Pass object with data

You can add _.template settings as a tplSettings property inside webpack config file to specify options for the loader, for example:

    ...
    tplSettings: {
        escape: /\{\{([^{].*?)\}\}/gm,
        interpolate: /\{\{\{(.+?)\}\}\}/gm,
        evaluate: /\{\%(.+?)\%\}/g
    }
    ...

License

MIT (http://www.opensource.org/licenses/mit-license.php)