https://github.com/grassator/tpl-loader
https://github.com/grassator/tpl-loader
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/grassator/tpl-loader
- Owner: grassator
- License: mit
- Created: 2014-12-15T14:49:38.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-15T16:55:30.000Z (about 11 years ago)
- Last Synced: 2024-04-25T07:22:36.595Z (over 1 year ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 1
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lodash template for webpack
Lodash template loader for [webpack](http://webpack.github.io/). Uses `_.template` function to compile templates.
## Installation
`npm install tpl-loader`
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
``` javascript
var template = require("tpl!./file.html");
// => returns the template function compiled with undesrcore (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:
``` javascript
...
tplSettings: {
escape: /\{\{([^{].*?)\}\}/gm,
interpolate: /\{\{\{(.+?)\}\}\}/gm,
evaluate: /\{\%(.+?)\%\}/g
}
...
```
## License
MIT (http://www.opensource.org/licenses/mit-license.php)