UNPKG

1.03 kBJavaScriptView Raw
1/**
2 * Created by Nikolay Glushchenko <nick@nickalie.com> on 08.09.2015.
3 */
4
5var gulp = require('gulp');
6var plumber = require('gulp-plumber');
7var concat = require('gulp-concat');
8var handlebars = require('gulp-handlebars');
9var wrap = require('gulp-wrap');
10var path = require('path');
11var common = require('./common');
12
13module.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 // Strip the extension and the underscore
23 // Escape the output with JSON.stringify
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