Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unic/gulp-unic-handlebars
https://github.com/unic/gulp-unic-handlebars
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/unic/gulp-unic-handlebars
- Owner: unic
- Created: 2015-04-15T09:02:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-15T09:02:39.000Z (over 9 years ago)
- Last Synced: 2024-04-14T05:50:41.829Z (9 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 23
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gulp-unic-handlebars
## Usage
First, install `gulp-unic-handlebars` as a development dependency:
```shell
npm install --save-dev gulp-unic-handlebars@git+https://[email protected]/unic/gulp-unic-handlebars.git
```Then, add it to your `gulpfile.js` (probably together with [gulp-rename](https://www.npmjs.com/package/gulp-rename)):
```javascript
var handlebars = require('gulp-unic-handlebars'),
rename = require('gulp-rename');gulp.task('html', function(){
gulp.src(['app/*.hbs'])
.pipe(handlebars({
data: function(file) {
return require('./app/' + path.basename(file.path, '.hbs') + '.json');
},
partials: ['./app/partials/*.hbs'],
getPartialName: function(filePath) {
var extension = path.extname(filePath),
name = path.relative('./app/partials/', filePath).replace(extension, '');return name.split(path.sep).join('/');
}
}))
.pipe(rename({
extname: '.html'
}))
.pipe(gulp.dest('dist/'));
});
```## Options
### options.data
Type: `Object|Function`Data object to pass to the template or function taking the template's path as argument (see example above).
### options.partials
Type: `String|Array`Glob or array of globs.
### options.getPartialName
Type: `Function`Transformation function for partial names taking the partial's path as argument (see example above).