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");
|
2014-12-15 22:48:11 +08:00
|
|
|
// => returns the template function compiled with undesrcore (lodash) templating engine.
|
|
|
|
|
|
|
|
// And then use it somewhere in your code
|
|
|
|
template(data) // Pass object with data
|
|
|
|
```
|
|
|
|
|
2014-12-16 00:55:16 +08:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|