Getting the Twig initiative done

alexpott's picture

Per Dries's post about Drupal 8 release risk, this post outlines a plan jointly developed by the Drupal core maintainers (Dries, webchick, catch, and alexpott) for getting Twig into core safely. See that post for more background information.

What's up with Twig?

The Twig template engine was originally committed to Drupal 8 live on stage at BADCamp in November 2012, to wild fanfare. Since then, the team has been working on converting all templates and theme functions in Drupal core to use Twig. Thanks to valiant effort by numerous contributors, the PHPTemplate conversions currently stand at ~30% RTBC, and another ~45% at needs review. This is great progress!

Why aren’t the core committers committing?

The short answer is release risk. We are in the “clean up” phase of the Drupal 8 release cycle ( Each commit we make should take us one step closer to a Drupal release. In effect, committing an individual Twig patch to core takes us one step further into uncharted territory. At the moment all of our templates are PHPTemplate and hence each conversion commit moves us further away from a release. We obviously can't ship with two theme systems, so unless 100% of templates are converted, we leave Drupal 8 in an unreleasable state.


We plan to merge all the PHPTemplate to Twig conversions into one patch. Once complete, we will commit this patch into the mainline 8.x branch. The patch will convert all the .tpl.php files to .twig and remove the functionality that allows Drupal 8 to run both theme engines at the same time. This means that Twig commits will not take the 8.x branch further away from a release, and it gives us an exit strategy if they are not complete by code freeze.

A meta issue has been created to track the merged patch.

The Twig team will:

  • Finish converting all the templates.
  • Provide benchmarking evidence on each issue that the conversion conforms to the acceptance criteria. If other patches are required to be applied in order to meet this requirements then these should added to both the conversion issue and the meta issue.

Core committers will:

  • Review each individual patch and
    • Comment: "+1. Ready for [#1987510]"
    • Status: "closed (duplicate)"
    • Title: prepend '[READY] '
  • Commit the merged patch once all templates have been converted and acceptance criteria have been met.
  • If a Twig patch is isolated to the current Twig code in 8.x then the core committers will commit it immediately. For example: Allow and test for NULL and integer 0 values in Twig templates

Acceptance criteria

The following are necessary in order to perform the final merge of conversions into 8.x:

  • 100% PHPTemplate to Twig conversions are completed
  • 8.x-twig performance is comparable with 8.x PHPTemplate performance, bearing in mind the issues with D8 performance testing - see
  • there are no critical Twig follow ups

Once the patch is committed further Twig work should continue on 8.x to:

  • Convert theme functions to Twig
  • Gain the security benefits on Twig
  • Further performance enhancements made possible by moving to Twig
  • Preprocess cleanup
  • Removal of the entire process layer

Important: It is in everyone’s interest that the conversions are finished as soon as possible. In an ideal world, the merge will take place during Drupalcon Portland.

Rollback criteria

If by 17th June the acceptance criteria are not met, then (with regret) an issue will be created to remove Twig from Drupal 8.x. This gives enough to time to create and test the rollback patch before code freeze on 1st July.

Help wanted!

The Twig team has been doing a tremendous job, and we know the front-end community is very excited about this initiative. The time is definitely here to jump in and help the team push this initiaitve past the finish line! Particularly needed are patch reviews (see for a helpful screencast on how to do so!), since most issues have patches but can't be RTBCed by people who worked on them.

So grab an issue to review and/or drop by #drupal-twig on IRC if you'd like to help. It's a great way to learn about Drupal 8, meet awesome people, and vastly improve Drupal for front-end developers at once!


page not found

junedkazi's picture

There is a
at the end for Dries post so it goes to a page not found.

Can you please update it.

Thanks @junedkazi

alexpott's picture

Thanks @junedkazi

drush extension to help diffing

clemens.tolboom's picture

I watch the video and wondered whether the diff workflow couldn't be more streamlined.

The following will grab the user page in a nice tree like format.

drush @drupal.d8 dom-get user



seosopt's picture

Many thanks for helping and for the solution. Regards

hello thanks

digiturkx's picture

This gives enough to time to create and test the rollback patch before code freeze on 1st July.

Rollback patch

boriss's picture


Why is the code freezing on 1st July? Is the developement planned to stop then?