About the Talk
August 21, 2012 1:00 PM
Munich, GermanyMunich, Germany
Problem: The Drupal 7 theme layer is inconsistent, insecure, and way too hard to learn. Goal: The goal is to make Drupal 8's theme layer, consistent, secure, and easy to learn.
Proposed Solution: The solution involves introducing Twig, a new theme engine created by the creators of Symfony, into Drupal 8.
All theme functions in core will be replaced by twig template files, meaning that for someone who needs to adjust markup - there will be only one way to do it: override a template file (not a theme function).
While we're creating a bunch of "new" template files, we'll get a chance to review all the markup that comes out of core, and restructure the use of these templates to be more consistent. For example, we'll be able to provide one "wrapper" template that can be used everywhere, rather than each module creating it's own, or adding its own wrapper around it's special markup.
Twig can flatten & sanitize all at the time of printing, meaning we can remove the whole "process" layer that exists in Drupal 7.
Much still needs to be decided about when the template gets called, since in twig-land the template should be called first, and what slides into that template is determined by the 'variables' that are printed within it. This is the opposite of how things are currently rendered in drupal-land.
Our pre-process layer may actually become a post-process layer, since the template gets called first, and if a 'variable' is requested that Twig doesn't know about yet, it will need to search the pre-process layer for what to print, and how it should be converted into HTML.
Twig will have it's own way of rendering objects such as nodes, comments, and users, so we should be able to remove (or replace) the whole "render" layer in the theme (keeping it of course, for things like forms).