You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tpl-loader/README.md

39 lines
905 B

# Lodash template for webpack
10 years ago
Lodash template loader for [webpack](http://webpack.github.io/). Uses `_.template` function to compile templates.
10 years ago
## Installation
10 years ago
`npm install tpl-loader`
10 years ago
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
``` javascript
var template = require("tpl!./file.html");
6 years ago
// => returns the template function compiled with underscore (lodash) templating engine.
10 years ago
// 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
}
...
```
10 years ago
## License
MIT (http://www.opensource.org/licenses/mit-license.php)