1 |
|
2 |
|
3 |
|
4 |
|
5 | var gulp = require('gulp');
|
6 | var plumber = require('gulp-plumber');
|
7 | var concat = require('gulp-concat');
|
8 | var handlebars = require('gulp-handlebars');
|
9 | var wrap = require('gulp-wrap');
|
10 | var path = require('path');
|
11 | var common = require('./common');
|
12 |
|
13 | module.exports = function ()
|
14 | {
|
15 | return gulp.src(['src/**/_*.hbs'])
|
16 | .pipe(plumber())
|
17 | .pipe(handlebars())
|
18 | .pipe(wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
|
19 | imports: {
|
20 | processPartialName: function (fileName)
|
21 | {
|
22 |
|
23 |
|
24 | return JSON.stringify(path.basename(fileName, '.js').substr(1));
|
25 | }
|
26 | }
|
27 | }))
|
28 | .pipe(concat('partials.js'))
|
29 | .pipe(gulp.dest(common.dist.main + '/templates'));
|
30 | }; |
\ | No newline at end of file |