Twigs and Sticks and Themes and Bones - but names will never hurt me!

By kattekrab, 10 April, 2013

Trumpets and drums. Hear the call!

[TL:DR - read this instead: Twig Status Update and Call for Contributors and start here: Convert core theme functions and templates to Twig]

The Drupal7 Theme system is impenetrable.  Drupal8 will very hopefully change all that, but we really need to rally the troops now and get it done.

We need an example TWIG theme so we can start seeing how it works, pull it apart, put it back together. We need to pour over the template and CSS files. We need to try to understand how they're calling functions, variables, thingies, widgets and whatsits! Then we can start to build the mental model in our minds, so we can fill it with new creative solutions.

But this is a chicken and egg problem... 

I've spent much of the morning trying to learn some PHP at codecademy.com. Why? Because I felt that my lack of understanding of PHP was holding back my ambition to be a Drupal themer when I grow up.

(Aside: I hit a bug I had to work around. Until such time as I realised it was a bug in the system - and not a bug in my thinking, I was feeling very stupid and incompetent. This is a surprisingly salient point. For people who are learning something new and unfamiliar, bugs, hacks and workarounds are unhelpful. Needing to know arcane or inscrutable incantations before starting to learn is not helpful. In fact, it is downright destructive when trying to create new neural pathways.)

I then went looking for something to explain why we have print render thingie instead of just print thingie... how is that helpful? I wondered. Who came up with that idea? I pondered. And, did they happen to explain themselves somewhere and will that help me see the light?

So, I turned to my trusty search engine and found these illuminating scrolls! [sorry, I mean blog posts]

Jacine Luisi had raised the alarm and said "Let’s Do Something About Drupal’s Theme System" and John Albin suggested that "Rethinking Drupal’s Theme/Render Layer was in order.

Around this time last year, the shift began. Most of the twists and turns are listed in this meta issue: New theme system It attracted 274 comments, and 37 mentions on IRC.

More recently, Jen Lampton has been doing lots of presentations on Twig Check out the slides and video from DrupalCon Sydney. And chx put out a public service announcement stating his support for Twig has less to do with Symfony, and more to do with Security. 

Morten chipped in some thoughts on the whole thing too http://morten.dk/blog/frontend-united-we-came-rock

It was around this time last year that the shift began.  And in November 2012, Twig was committed to Drupal8.

So, now we have Twig. But what is Twig? It's a modern PHP template engine. Here's node.tpl.php converted into a Twig template.

http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/core/modules/node/templates/node.html.twig

Please - please - if you care at all about the future of Drupal dive in now. This is important. Really.

Start here: Convert core theme functions and templates to Twig