Git Product home page Git Product logo

metalsmith-twig's People

Contributors

dependabot[bot] avatar joecritch avatar pkuebler avatar thiagodemellobueno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

metalsmith-twig's Issues

Error compiling Twig templates with v1.1.0

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
  }))

Extending metalsmith-twig

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?

TypeError: metalsmith.path is not a function

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?

Using ignore missing in include causes TwigException

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?

How to run the tests?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.