Skip to content
This repository was archived by the owner on Sep 15, 2023. It is now read-only.

Commit c5f1ca0

Browse files
committed
Merge branch 'twig'
2 parents 3a83cdf + 36ea182 commit c5f1ca0

File tree

6 files changed

+83
-11
lines changed

6 files changed

+83
-11
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v8.16.2

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node v8.16.2

gulpfile.js/lib/task-defaults.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ module.exports = {
5555

5656
html: {
5757
dataFile: "data/global.json",
58-
nunjucksRender: {
59-
envOptions: {
60-
watch: false
61-
}
62-
},
58+
excludeFolders: ["layouts", "shared", "macros", "data"],
59+
extensions: ["html", "njk", "json"],
6360
htmlmin: {
6461
collapseWhitespace: true
6562
},
66-
excludeFolders: ["layouts", "shared", "macros", "data"],
67-
extensions: ["html", "njk", "json"]
63+
nunjucksRender: {},
64+
templateLanguage: 'nunjucks',
65+
twig: {},
6866
},
6967

7068
images: {

gulpfile.js/tasks/html.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const handleErrors = require('../lib/handleErrors')
99
const htmlmin = require('gulp-htmlmin')
1010
const nunjucksRender = require('gulp-nunjucks-render')
1111
const projectPath = require('../lib/projectPath')
12+
const twig = require('gulp-twig')
1213
const yaml = require('js-yaml')
1314

1415
const htmlTask = function() {
@@ -34,13 +35,21 @@ const htmlTask = function() {
3435
return data
3536
}
3637

37-
const nunjucksRenderPath = [ projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src) ]
38-
TASK_CONFIG.html.nunjucksRender.path = TASK_CONFIG.html.nunjucksRender.path || nunjucksRenderPath
38+
const templateBasePath = [ projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src) ]
39+
let templateParser
40+
41+
if (TASK_CONFIG.html.templateLanguage === 'twig') {
42+
TASK_CONFIG.html.twig.base = TASK_CONFIG.html.twig.base || templateBasePath
43+
templateParser = twig(TASK_CONFIG.html.twig)
44+
} else {
45+
TASK_CONFIG.html.nunjucksRender.path = TASK_CONFIG.html.nunjucksRender.path || templateBasePath
46+
templateParser = nunjucksRender(TASK_CONFIG.html.nunjucksRender)
47+
}
3948

4049
return gulp.src(paths.src)
4150
.pipe(data(dataFunction))
4251
.on('error', handleErrors)
43-
.pipe(nunjucksRender(TASK_CONFIG.html.nunjucksRender))
52+
.pipe(templateParser)
4453
.on('error', handleErrors)
4554
.pipe(gulpif(global.production, htmlmin(TASK_CONFIG.html.htmlmin)))
4655
.pipe(gulp.dest(paths.dest))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"gulp-sizereport": "1.2.1",
5555
"gulp-sourcemaps": "^2.6.5",
5656
"gulp-svgstore": "7.0.1",
57+
"gulp-twig": "^1.2.0",
5758
"js-yaml": "^3.13.1",
5859
"lodash": "^4.17.11",
5960
"merge-stream": "^1.0.1",

yarn.lock

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# yarn lockfile v1
33

44

5+
"@babel/runtime@^7.6.3":
6+
version "7.7.2"
7+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.2.tgz#111a78002a5c25fc8e3361bedc9529c696b85a6a"
8+
integrity sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==
9+
dependencies:
10+
regenerator-runtime "^0.13.2"
11+
512
"@gulp-sourcemaps/identity-map@1.X":
613
version "1.0.2"
714
resolved "https://registry.yarnpkg.com/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz#1e6fe5d8027b1f285dc0d31762f566bccd73d5a9"
@@ -2648,6 +2655,11 @@ es6-promise@^2.3.0:
26482655
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-2.3.0.tgz#96edb9f2fdb01995822b263dd8aadab6748181bc"
26492656
integrity sha1-lu258v2wGZWCKyY92KratnSBgbw=
26502657

2658+
es6-promise@^4.2.5:
2659+
version "4.2.8"
2660+
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a"
2661+
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==
2662+
26512663
es6-promise@^4.2.6:
26522664
version "4.2.6"
26532665
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.6.tgz#b685edd8258886365ea62b57d30de28fadcd974f"
@@ -3048,6 +3060,11 @@ for-own@^1.0.0:
30483060
dependencies:
30493061
for-in "^1.0.1"
30503062

3063+
foreachasync@^3.0.0:
3064+
version "3.0.0"
3065+
resolved "https://registry.yarnpkg.com/foreachasync/-/foreachasync-3.0.0.tgz#5502987dc8714be3392097f32e0071c9dee07cf6"
3066+
integrity sha1-VQKYfchxS+M5IJfzLgBxyd7gfPY=
3067+
30513068
forever-agent@~0.6.1:
30523069
version "0.6.1"
30533070
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
@@ -3594,6 +3611,17 @@ gulp-svgstore@7.0.1:
35943611
plugin-error "^0.1.2"
35953612
vinyl "^2.1.0"
35963613

3614+
gulp-twig@^1.2.0:
3615+
version "1.2.0"
3616+
resolved "https://registry.yarnpkg.com/gulp-twig/-/gulp-twig-1.2.0.tgz#a36879bda142252d88bad196c78b8b8b5656475f"
3617+
integrity sha512-FlBIq4wgZo0eSOpOOl4M9gM8RGo6MBev8h29st+9c+T0UTwlYE/XKp9CV9LCfdOCXblOmC/Bqe+X9580NAK3Mg==
3618+
dependencies:
3619+
fancy-log "^1.3.2"
3620+
map-stream "^0.1.0"
3621+
plugin-error "^0.1.2"
3622+
replace-ext "^1.0.0"
3623+
twig "^1.10.5"
3624+
35973625
gulp-util@^3.0.0, gulp-util@^3.0.7:
35983626
version "3.0.8"
35993627
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f"
@@ -4655,6 +4683,13 @@ locate-path@^3.0.0:
46554683
p-locate "^3.0.0"
46564684
path-exists "^3.0.0"
46574685

4686+
locutus@^2.0.5:
4687+
version "2.0.11"
4688+
resolved "https://registry.yarnpkg.com/locutus/-/locutus-2.0.11.tgz#83f85109971fd3dd620482a04381916e4a31d4f0"
4689+
integrity sha512-C0q1L38lK5q1t+wE0KY21/9szrBHxye6o2z5EJzU+5B79tubNOC+nLAEzTTn1vPUGoUuehKh8kYKqiVUTWRyaQ==
4690+
dependencies:
4691+
es6-promise "^4.2.5"
4692+
46584693
lodash._basecopy@^3.0.0:
46594694
version "3.0.1"
46604695
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
@@ -4974,6 +5009,11 @@ map-obj@^1.0.0, map-obj@^1.0.1:
49745009
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"
49755010
integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=
49765011

5012+
map-stream@^0.1.0:
5013+
version "0.1.0"
5014+
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"
5015+
integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=
5016+
49775017
map-visit@^1.0.0:
49785018
version "1.0.0"
49795019
resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
@@ -5144,7 +5184,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
51445184
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
51455185
integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=
51465186

5147-
"minimatch@2 || 3", minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
5187+
"minimatch@2 || 3", minimatch@3.0.4, minimatch@3.0.x, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
51485188
version "3.0.4"
51495189
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
51505190
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
@@ -6737,6 +6777,11 @@ regenerator-runtime@^0.11.0:
67376777
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
67386778
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
67396779

6780+
regenerator-runtime@^0.13.2:
6781+
version "0.13.3"
6782+
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5"
6783+
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==
6784+
67406785
regenerator-transform@^0.10.0:
67416786
version "0.10.1"
67426787
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd"
@@ -7895,6 +7940,16 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
78957940
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
78967941
integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=
78977942

7943+
twig@^1.10.5:
7944+
version "1.14.0"
7945+
resolved "https://registry.yarnpkg.com/twig/-/twig-1.14.0.tgz#64b64d4dae3e34c157f356a270d7dfff9ee3aa0c"
7946+
integrity sha512-ut1LslUKAeF56TYQglabJaATUqbNuGO3EcXDhUspAdNbxez5VwTk2n8H00V0VfNy9Scet+VGQP8oPxt4v6mykQ==
7947+
dependencies:
7948+
"@babel/runtime" "^7.6.3"
7949+
locutus "^2.0.5"
7950+
minimatch "3.0.x"
7951+
walk "2.3.x"
7952+
78987953
type-detect@0.1.1:
78997954
version "0.1.1"
79007955
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
@@ -8236,6 +8291,13 @@ vm-browserify@0.0.4:
82368291
dependencies:
82378292
indexof "0.0.1"
82388293

8294+
walk@2.3.x:
8295+
version "2.3.14"
8296+
resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.14.tgz#60ec8631cfd23276ae1e7363ce11d626452e1ef3"
8297+
integrity sha512-5skcWAUmySj6hkBdH6B6+3ddMjVQYH5Qy9QGbPmN8kVmLteXk+yVXg+yfk1nbX30EYakahLrr8iPcCxJQSCBeg==
8298+
dependencies:
8299+
foreachasync "^3.0.0"
8300+
82398301
watchpack@^1.4.0:
82408302
version "1.6.0"
82418303
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"

0 commit comments

Comments
 (0)