tpl-loader/README.md

39 lines
905 B
Markdown
Raw Permalink Normal View History

2014-12-15 23:00:49 +08:00
# Lodash template for webpack
2014-12-15 22:48:11 +08:00
2014-12-15 23:00:49 +08:00
Lodash template loader for [webpack](http://webpack.github.io/). Uses `_.template` function to compile templates.
2014-12-15 22:48:11 +08:00
## Installation
2014-12-15 22:52:26 +08:00
`npm install tpl-loader`
2014-12-15 22:48:11 +08:00
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
``` javascript
2014-12-15 23:00:49 +08:00
var template = require("tpl!./file.html");
2018-05-10 22:15:04 +08:00
// => returns the template function compiled with underscore (lodash) templating engine.
2014-12-15 22:48:11 +08:00
// 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:
``` javascript
...
tplSettings: {
escape: /\{\{([^{].*?)\}\}/gm,
interpolate: /\{\{\{(.+?)\}\}\}/gm,
evaluate: /\{\%(.+?)\%\}/g
}
...
```
2014-12-15 22:48:11 +08:00
## License
MIT (http://www.opensource.org/licenses/mit-license.php)