This repository has been archived by the owner on Nov 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (55 loc) · 1.53 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
const gulp = require('gulp');
const rename = require('gulp-rename');
const twig2html = require('./');
gulp.task('pages', () => {
return gulp.src('test/fixtures/pages/*.twig')
.pipe(twig2html({
globals: './test/fixtures/globals.json',
context: {
year: 2017
},
namespaces: {
blocks: './test/fixtures/blocks/'
}
}))
.pipe(rename({extname: '.html'}))
.pipe(gulp.dest('tmp'));
});
gulp.task('functions', () => {
return gulp.src('test/fixtures/functions/*.twig')
.pipe(twig2html({
globals: './test/fixtures/globals.json',
functions: {
greeting: function (name) {
return 'Hello, ' + name + '!';
}
},
context: {
name: 'Test'
}
}))
.pipe(rename({extname: '.html'}))
.pipe(gulp.dest('tmp'));
});
gulp.task('filters', () => {
return gulp.src('test/fixtures/filters/*.twig')
.pipe(twig2html({
globals: './test/fixtures/globals.json',
filters: {
tel: function (str) {
return str.replace(/([^0-9+])/g, '');
}
},
context: {
phone: '+7 (999) 888-77-66'
}
}))
.pipe(rename({extname: '.html'}))
.pipe(gulp.dest('tmp'));
});
gulp.task('default', gulp.parallel(
'pages',
'functions',
'filters'
));