14

I do a lot of Django development and I like their templating language. Twig, the new templating engine in Drupal 8, looks very much like it.

How can I use Twig in Drupal 7 or even Drupal 6?

  • 5
    There's a sandbox module for Drupal 7, I don't think there's a D6 solution out there but I might be wrong – Clive May 13 '13 at 19:59
  • Was the sandbox module enough? Write an answer and accept it, so this question is considered closed. – Capi Etheriel Aug 28 '13 at 13:19
  • Not really. I'm not looking for experimental stuff. Though I think it's unlikely that this will ever be answered satisfactory. So if @Clive formulates an answer along the lines of "nothing stable, but here's some sand", I'd have to accept it. – Chris Wesseling Aug 28 '13 at 14:08
  • @ChrisWesseling No forced-accepts over here ;) I'd save leave it open-ended, at some point when D8 is out in the wild someone will have a stable solution and then it'll be this q's time to shine! – Clive Aug 28 '13 at 14:10
  • @clive, judging on the upvotes, there's at least 5 of us in the world, that would love to see this. :-) – Chris Wesseling Aug 28 '13 at 14:11
13

Yes, you can, here is an article about my own experience with it, working with Bootstrap http://makina-corpus.com/blog/metier/2015/develop-with-twig-in-drupal-7

So http://www.drupal.org/project/tfd7 is the way to go if you want to write template files with Twig syntax, it must be moved to theme/engines. Note that development is now happening at https://github.com/TFD7/TFD7 and documentation is at http://tfd7.rocks.

Don't be confused with the project https://drupal.org/project/twig, unfortunately, it is only an input filter because modules cannot provide theme engines in Drupal 7 (due to license reasons it seems).

  • When I upgrade my D6 site to D7, this will work for me. Till then I'll keep this open, in case a D6 solution shows up. For now, "just" the upvote. Thanks – Chris Wesseling Sep 3 '13 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.