simon-dt / gulp-twig

Twig plugin for gulp.js, The streaming build system. Looking for maintainer or collaborators. See wiki
https://github.com/zimmen/gulp-twig/wiki/Looking-for-maintainer-or-collaborator(s)
MIT License
62 stars 33 forks source link

Error compiling twig template #3

Closed Nickstr closed 9 years ago

Nickstr commented 9 years ago

I'm having an issue with using extends() and compiling my twig.

I have the following folder structure

My invitation file extends using the following code:

{% extends('email.layouts.single-column.twig') %}

This works perfect with the PHP compiler but is giving me the following error using this package:

Error compiling twig template /Users/sites/site/app/views/email/invitation.twig: 
TwigException: Unable to parse 'extends('email.layouts.single-column.twig')'
Error parsing twig template /Users/sites/site/app/views/email/invitation.twig: 
TypeError: Cannot call method 'forEach' of undefined

Gulp task

g.task('inline-css', function() {
    return g.src(['./app/views/email/**/*.twig', '!./app/views/email/layouts/**/*.twig'])
        .pipe(twig({
            base: './app/views'
        }))
        .pipe(g.dest('./app/views/email/inline'))
});
simon-dt commented 9 years ago

Hi Nick,

The base property isn't currently exposed directly. I'll fix that (and add debug and trace options too).

Those dots are PHP or Symfony3 specific as far as i know. What I can do is expose the base property so wou can set that to your views folder and reference the layout like this:

{% extends('email/layouts/single-column.twig') %}

[update] fa43e33c77ede45553985cfc6aaab8e0227b213d

Nickstr commented 9 years ago

Just pulled down the latest update and it all works now. Thanks for the fast response and fix!

simon-dt commented 9 years ago

You're welcome!