1 | var gulp = require('gulp');
|
2 |
|
3 | gulp.task('compile', function () {
|
4 | 'use strict';
|
5 | var twig = require('gulp-twig');
|
6 | return gulp.src('./index.twig')
|
7 | .pipe(twig({
|
8 | data: {
|
9 | title: 'Gulp and Twig',
|
10 | benefits: [
|
11 | 'Fast',
|
12 | 'Flexible',
|
13 | 'Secure'
|
14 | ]
|
15 | }
|
16 | }))
|
17 | .pipe(gulp.dest('./'));
|
18 | });
|
19 |
|
20 |
|
21 | gulp.task('data-example', function () {
|
22 | 'use strict';
|
23 |
|
24 | var twig = require('gulp-twig');
|
25 | var data = require('gulp-data');
|
26 |
|
27 | return gulp.src('./index-json.twig')
|
28 | .pipe(data(function(file) {
|
29 | return require('./example/index-data.json');
|
30 | }))
|
31 | .pipe(twig())
|
32 | .pipe(gulp.dest('./'));
|
33 | });
|
34 |
|
35 |
|
36 | gulp.task('default', ['compile', 'data-example']);
|