Drupal 7's theme layer suffered from "Arrays of Doom" and the impenetrable render(). After having to learn and use these tools, the community has rebelled and decided we need to make some major changes in Drupal 8.
Come learn about Twig, a new Symfonic templating language we can use to decrease Drupal's learning curve and increase security on every Drupal site.
3. I AM c4rl
(Carl Wiedemann)
working with Drupal (since D5)
training instructor (since D6)
drupal.org redesign team
I care a lot about _?_
Saturday, July 21, 2012
4. I AM jenlampton
(Jen Lampton)
working with Drupal (since D4.7)
training instructor (since D6)
conrib maintainer (youtube, more) since D5
I care a lot about usability & learnability
Saturday, July 21, 2012
6. YOU ARE:
Theme developers?
(D7? D6? D5?)
Saturday, July 21, 2012
7. YOU ARE:
Theme developers?
(D7? D6? D5?)
New to Drupal?
(just want to know what the heck is going on in D8)
Saturday, July 21, 2012
8. YOU ARE:
Theme developers?
(D7? D6? D5?)
New to Drupal?
(just want to know what the heck is going on in D8)
Drupal Experts?
(also want to know what the heck is going on in D8)
Saturday, July 21, 2012
9. DRUPAL 8 :
A NEW THEME LAYER
Saturday, July 21, 2012
10. DRUPAL 8 :
A NEW THEME LAYER
(probably)
Saturday, July 21, 2012
34. TWIG
A modern template engine for PHP.
http://twig.sensiolabs.org
Saturday, July 21, 2012
35. TWIG
what’s so great about it?
• well documented
• extensible
• secure
• well tested
• IDE integration
• recognizable syntax
• Python (django)
• JS (TwigJS)
•Ruby (Liquid)
•by Symfony’s author, Fabien Potencier
Saturday, July 21, 2012
36. TWIG
what does it look like?
Saturday, July 21, 2012
37. TWIG
what does it look like?
print with {{ }}
Saturday, July 21, 2012
38. TWIG
what does it look like?
commands with {% %}
Saturday, July 21, 2012
39. TWIG
what does it look like?
comments with {# #}
Saturday, July 21, 2012
40. TWIG
what does it look like?
simple and intuitive
Saturday, July 21, 2012
41. INTERLUDE:
attributes
attributes are messy
Saturday, July 21, 2012
42. INTERLUDE:
attributes
HTML5 attribute types:
String
Boolean
Enumerated
attributes are messy
Saturday, July 21, 2012
43. INTERLUDE:
attributes
We need attributes to be “drillable”
attributes
or
attributes.class
or
attributes.id
Saturday, July 21, 2012
44. INTERLUDE:
attributes
PHP5 to the rescue!
ArrayAccess
allows objects to be treated as arrays
__toString
allows “flattening” of arrays or objects into HTML strings
(almost)
Saturday, July 21, 2012
45. INTERLUDE:
attributes
but, this has nothing to do with TWIG.
so
let’s do it now:
http://drupal.org/node/1290694
Saturday, July 21, 2012
46. TWIG
how would it work?
all theme functions become template files.
a single way to override markup!
Saturday, July 21, 2012