Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meilleursagents/gulp-lodash-compile
https://github.com/meilleursagents/gulp-lodash-compile
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/meilleursagents/gulp-lodash-compile
- Owner: MeilleursAgents
- Created: 2015-10-20T13:37:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-11T09:52:12.000Z (over 8 years ago)
- Last Synced: 2024-11-13T07:33:56.180Z (2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 32
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Gulp plugin to compile HTML templates to JavaScript functions using lodash.
## Usage
In `templates/test.html`:
```html
Hello <%= place %>
```In your gulpfile:
```javascript
var compiler = require('gulp-lodash-compile');gulp.task('templates', function() {
gulp.src('templates/**/*.html')
.pipe(compiler('templates.js'));
.pipe(gulp.dest('js/'));
});
```In your JavaScript:
```javascript
var templates = require('js/templates.js');
var html = templates.test({
place: 'world';
})
```## Parameters
* file `string`
* The name of the file to use for the compiled templates
* options `object`
* Options passed to the task## Options
### newLine `string`
The line delimiter, defaults to your operating system's newline.
### wrapper `string`
Either `amd`, `commonjs` or `false` for no wrapper, defaults to `amd`. If wrapper is `false` a local var `templates` will be defined containing the templates.
### templateName `function(file)`
A function that will be passed the file and should return a name for the template. By default uses the basename of the file without an extension.
### templateSettings `object`
An object to pass to [_template function](https://lodash.com/docs#template)