pkuebler / metalsmith-twig Goto Github PK
View Code? Open in Web Editor NEWA metalsmith plugin for twig
License: MIT License
A metalsmith plugin for twig
License: MIT License
Our builds started failing on our Jenkins server last night with the only change being v1.1.0 of metalsmith-twig getting installed with the npm install
run.
06:18:49 > cross-env NODE_ENV=development node index.js 2>&1 | tee output.log
06:18:49
06:18:57 Error compiling twig template /jenkins/workspace/myProjectName/views/explore.twig:
06:18:57 TwigException: Twig.expression.type.variable cannot follow a Twig.expression.type.variable at template:6 near 'missing...'
06:18:57 /jenkins/workspace/myProjectName/node_modules/twig/twig.js:7514
06:18:57 if (index == arr.length) {
06:18:57 ^
06:18:57
06:18:57 TypeError: Cannot read property 'length' of undefined
06:18:57 at iterate (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:7514:30)
06:18:57 at Object.forEachAsync [as forEach] (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:7522:10)
06:18:57 at Twig.parse (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:875:31)
06:18:57 at Twig.parseAsync (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:7313:28)
06:18:57 at Twig.Template.render (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:1379:36)
06:18:57 at load (/jenkins/workspace/myProjectName/node_modules/metalsmith-twig/lib/index.js:54:42)
06:18:57 at loadTemplateFn (/jenkins/workspace/myProjectName/node_modules/twig/twig.js:5726:18)
06:18:57 at tryToString (fs.js:456:3)
06:18:57 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
We rolled back and locked metalsmith-twig
at 1.0.4 for now, but I'd like to look into what happened. It seems like the only changes are upstream package bumps to twig and async. Possibly a breaking change upstream there?
Our metalsmith config uses this for the twig config:
.use(twig({
directory: 'views',
cache: false
}))
Hey dudes - I keep getting this error when I use this with the replacement for the metalsmith-templates module, specifically, the new metalsmith-in-place and metalsmith-layouts modules. Not sure what's happening.
I thought maybe this was the fix:
https://github.com/genexp/metalsmith-twig/blob/master/lib/index.js#L46
But alas, no.
I'm trying to extend Twig with more filters (via a metalsmith plugin that implements them and is instantiated before the twig plugin):
Metalsmith('test/fixtures/simple')
.use(markdown())
.use(twigFilters)
.use(mTwig({
directory: 'templates'
}));
But it seems like some modifications would be necessary to metalsmith-twig to allow for this sort of extension... such as passing an extended twig instance into metalsmith-twig use(twig({twig: extendedTwig})
or something similar.
What are your thoughts on this? Or am I missing something basic?
Just initiate a new metalsmith to try Twig, but at the build with the simplest configuration i have this error:
`Metalsmith {
dir: '/private/var/www/perso/starter-kit',
ware: Ware { fns: [ [Function] ] },
data: {},
_src: 'src',
_dest: 'build' }
/private/var/www/perso/starter-kit/node_modules/metalsmith-twig/lib/index.js:33
var path = metalsmith.path(dir, data.view);
^
TypeError: metalsmith.path is not a function
at /private/var/www/perso/starter-kit/node_modules/metalsmith-twig/lib/index.js:33:26
at /private/var/www/perso/starter-kit/node_modules/metalsmith-twig/node_modules/async/lib/async.js:181:20
at Object.async.forEachOf.async.eachOf (/private/var/www/perso/starter-kit/node_modules/metalsmith-twig/node_modules/async/lib/async.js:233:13)
at async.forEach.async.each (/private/var/www/perso/starter-kit/node_modules/metalsmith-twig/node_modules/async/lib/async.js:209:22)
at /private/var/www/perso/starter-kit/node_modules/metalsmith-twig/lib/index.js:27:3
at Timeout.next as _onTimeout
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)`
It's a bug on the module or something I've done wrong?
Getting an error when trying to use ignore missing
in an include instead a template.
Here's the call I'm using:
{% include '_partials/my_partial_file.twig' ignore missing %}
When I try to run a build, I get the following errors:
Error compiling twig template /Users/my_user/my_project_dir/views/my_view.twig:
TwigException: Twig.expression.type.variable cannot follow a Twig.expression.type.variable at template:10 near 'ignore...'
Error parsing twig template /Users/my_user/my_project_dir/views/my_view.twig:
TypeError: Cannot read property 'forEach' of undefined
at Object.Twig.forEach (/Users/my_user/my_project_dir/node_modules/twig/twig.min.js:8:821)
at Twig.parse (/Users/my_user/my_project_dir/node_modules/twig/twig.min.js:8:11203)
at Twig.Template.render (/Users/my_user/my_project_dir/node_modules/twig/twig.min.js:8:16150)
at load (/Users/my_user/my_project_dir/node_modules/metalsmith-twig/lib/index.js:45:42)
at loadTemplateFn (/Users/my_user/my_project_dir/node_modules/twig/twig.min.js:8:20154)
at tryToString (fs.js:455:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
buffer.js:259
throw new TypeError(kFromErrorMsg);
^
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at fromObject (buffer.js:259:9)
at Function.Buffer.from (buffer.js:96:10)
at new Buffer (buffer.js:75:17)
at load (/Users/my_user/my_project_dir/node_modules/metalsmith-twig/lib/index.js:45:22)
at loadTemplateFn (/Users/my_user/my_project_dir/node_modules/twig/twig.min.js:8:20154)
at tryToString (fs.js:455:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
Taking out ignore missing
gives a successful build, but there will be cases where I'm looping through things and an include for a particular file might not exist. Any thoughts on getting this to work, or a workaround?
I've noticed that your test has a Jasmine-like describe
it
dependency. Along with a make test
command listed in the package.json
.
How should the tests be run? Are there some global prerequisites?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.