Lodash html template for webpack
Combination of the html-loader and the underscore-loader for webpack. Uses the _.template
function to extract assets.
Installation
npm install html-tpl-loader --save-dev
Usage
var template = ;// => returns the template function compiled with underscore (lodash) templating engine.// And then use it somewhere in your code// Pass object with data
Alternatively you can also define html-tpl in your webpack.config file:
module:loaders:test: "\.tpl.html$" loader: "html-tpl"
var template = ;
The html-tpl loader allows you to minify the html before compiling by setting a loader query string
module:loaders:test: "\.tpl.html$" loader: "html-tpl?minimize=true"
The html-tpl loader allows you to not to add lodash before compiling by setting a loader query string
module:loaders:test: "\.tpl.html$" loader: "html-tpl?lodash=false"
The html-tpl loader allows you to configure lodash template settings by setting a loader query string
module:loaders:test: "\.tpl.html$" loader: "html-tpl?evaluate=\\{\\[([\\s\\S]+?)\\]\\}&interpolate=\\{\\{([\\s\\S]+?)\\}\\}"
Tests
Run unit tests:
npm install
npm test
Demo
http://jantimon.github.io/html-tpl-loader/
License
MIT (http://www.opensource.org/licenses/mit-license.php)