Skip to content

Instantly share code, notes, and snippets.

@stowball
Created March 14, 2016 17:43
Show Gist options
  • Select an option

  • Save stowball/f91f305cb825ea812cb1 to your computer and use it in GitHub Desktop.

Select an option

Save stowball/f91f305cb825ea812cb1 to your computer and use it in GitHub Desktop.
trying to get twig data to work
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var twig = require('gulp-twig');
var data = require('gulp-data');
var getJsonData = function(file) {
var foo = path.join(conf.paths.builds, '/data/', path.basename(file.path.replace('twig.html', 'json')));
console.log(foo);
return require(foo);
};
gulp.task('twig-templates', function () {
return gulp.src([
path.join(conf.paths.builds, '/*.twig.html')
])
.pipe(data(getJsonData))
.pipe(twig())
.pipe(gulp.dest(conf.paths.src));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment