pattern-lab / patternengine-node-twig

ARCHIVED - The Twig engine for Patternlab/Node
MIT License
7 stars 9 forks source link

Replacing mustache with twig in node edition of patternlab? #2

Open bmiller59 opened 8 years ago

bmiller59 commented 8 years ago

Hi. I am using Pattern Lab Node v2.0.0 on Mac, using the gulp edition.

I am trying to get patternlab gulp node set up to use twig rather than mustache since we are working towards a wordpress theme using twig but use gulp for our front end workflow.

I npm installed patternengine-node-twig and then manually dropped in the source files from starterkit-twig-demo and fired up gulp patternlab:serve but I got a lot of "Invalid template!" errors during build.

Error detail: [TypeError: Invalid template! Template should be a "string" but "undefined" was given as the first argument for mustache#render(template, view, partials)]

Can you sketch out the additional config changes to get patternlab node edition working with twig templates instead of mustache templates?

I appreciate it.

geoffp commented 8 years ago

Hey! The Twig engine is super early in its life, and hasn't reached what I would call a point of stability yet. That said, I'm getting exactly the same errors in a project I'm doing right now with Handlebars, so stay tuned.

bmiller59 commented 8 years ago

Thanks for the quick reply. Let me know what you find out. :)

geoffp commented 8 years ago

This bug (https://github.com/pattern-lab/patternlab-node/issues/418) describes my issue. Do you think that's related to yours?

bmiller59 commented 8 years ago

Hmmm. It could be, but the feeling I get is that it is a more general problem where patternlab is trying to use mustache to render the twig files rather than the twig engine...

geoffp commented 8 years ago

It's possible! I'd encourage you to hack on your copy of the twig engine and do a little debugging if you're up for it. If you put a console.log() in the renderPattern method of the twig engine you could test that theory.

bmiller59 commented 8 years ago

We decided to go another route with our workflow for now, so I do not need this right now. Feel free to close if you would like. Thank you.

gael-boyenval commented 7 years ago

I would love to see twig engine native. Another more stable alternative is Nunjucks (since 2012, by mozila) https://mozilla.github.io/nunjucks/ most of the features of twig are implemented in nunjucks (maybe more), and the syntax is very very close to twig.js.

dnwhte commented 7 years ago

+1 for Nunjucks. Been thinking about trying to build the engine myself, but not sure where to begin.

dnwhte commented 7 years ago

If anyone is interested, I've been working on a Nunjucks engine. It's still early, but it appears to be working well. Find it at https://github.com/pattern-lab/patternengine-node-nunjucks.

bmuenzenmeyer commented 7 years ago

@danwhite85 this is awesome! I have yet to check it out but am crazy excited by the prospect. (saw you email too, will respond as soon as I unbury the rest of my inbox)

@katiemfritz were you hoping for a nunjucks solution?

KatieMFritz commented 7 years ago

@bmuenzenmeyer I was looking into it earlier this year as an alternative to the Twig engine for PL Node (which was missing some key features). I'm going in a different direction now though (Vue).

However, if you (@danwhite85) need help testing it out, I'd be happy to help.