@@ -8,6 +8,7 @@ var settings = {
88 scripts : true ,
99 polyfills : true ,
1010 styles : true ,
11+ templates : true ,
1112 svgs : true ,
1213 copy : true ,
1314 reload : true
@@ -30,6 +31,11 @@ var paths = {
3031 input : 'src/sass/**/*.{scss,sass}' ,
3132 output : 'dist/css/'
3233 } ,
34+ templates : {
35+ twig : 'src/templates/**/*.twig' ,
36+ html_pages : 'src/templates/pages/**/*.twig' ,
37+ dataJson : 'src/data/**/*.json' ,
38+ } ,
3339 svgs : {
3440 input : 'src/svg/*.svg' ,
3541 output : 'dist/svg/'
@@ -91,6 +97,11 @@ var sourcemaps = require('gulp-sourcemaps');
9197var prefix = require ( 'gulp-autoprefixer' ) ;
9298var minify = require ( 'gulp-cssnano' ) ;
9399
100+ // Templates
101+ var twig = require ( 'gulp-twig' ) ,
102+ path = require ( 'path' ) ,
103+ data = require ( 'gulp-data' ) ;
104+
94105// SVGs
95106var svgmin = require ( 'gulp-svgmin' ) ;
96107
@@ -221,6 +232,46 @@ var buildStyles = function (done) {
221232
222233} ;
223234
235+
236+
237+ // // Generate templates
238+ // gulp.task('templates', function () {
239+ // return gulp.src(src.html_pages)
240+ // .pipe(data(function (file) {
241+ // var dataPath = '../data/' + path.join(path.relative("../templates/pages", path.dirname(file.path)), path.basename(file.path, '.twig')) + '.json';
242+ // return requireUncached(dataPath);
243+ // }))
244+ // .pipe(twig())
245+ // .pipe(prettify({indent_char: ' ', indent_size: 2}))
246+ // .pipe(gulp.dest('../'))
247+ // .on("end", reload);
248+ // });
249+
250+ // paths.
251+ // templates: {
252+ // twig: '../templates/**/*.twig',
253+ // html_pages: '../templates/pages/**/*.twig',
254+ // dataJson: '../data/**/*.json',
255+ // },
256+
257+ // Generate html from templates and data
258+ var buildTemplates = function ( done ) {
259+
260+ //if (!settings.templates) return done();
261+
262+ return src ( paths . templates . html_pages )
263+ // .pipe(data(function (file) {
264+ // var dataPath = 'src/data/' + path.join(path.relative("src/templates/pages", path.dirname(file.path)), path.basename(file.path, '.twig')) + '.json';
265+ // return requireUncached(dataPath);
266+ // }))
267+ . pipe ( twig ( ) )
268+ //.pipe(prettify({indent_char: ' ', indent_size: 2}))
269+ . pipe ( dest ( paths . output ) ) ;
270+ } ;
271+
272+
273+
274+
224275// Optimize SVG files
225276var buildSVGs = function ( done ) {
226277
@@ -291,6 +342,7 @@ exports.default = series(
291342 buildScripts ,
292343 lintScripts ,
293344 buildStyles ,
345+ buildTemplates ,
294346 buildSVGs ,
295347 copyFiles
296348 )
0 commit comments