SlideShare a Scribd company logo
THE NEW THEME LAYER
          IN DRUPAL 8
                           Jen Lampton




Thursday, April 11, 2013
JEN LAMPTON

                                   @jenlampton on twitter
                           ā€œjenlamptonā€ http://drupal.org/user/85586
                                    www.jenlampton.com
                                               Ā 




                 if you forget my name, just Google ā€œDrupal developerā€




Thursday, April 11, 2013
MY BACKGROUND


                                         Ā 




                            Building websites since 1997
Thursday, April 11, 2013
MY BACKGROUND


                                          Ā 




                            Working with Drupal since 2006
Thursday, April 11, 2013
MY BACKGROUND


                                         Ā 




                            Consider myself a developer.
Thursday, April 11, 2013
MY BACKGROUND


                                        Ā 




                              Also a Drupal trainer.
Thursday, April 11, 2013
MY BACKGROUND


                                              Ā 




                           Accidental Drupal 8 ā€œinitiativeā€ leader.
Thursday, April 11, 2013
MY ā€œINITIATIVEā€
                                (unofļ¬cial)




                                     Ā 




Thursday, April 11, 2013
MY ā€œINITIATIVEā€
                                (unofļ¬cial)




                                     Ā 




       A new theme layer for Drupal 8

Thursday, April 11, 2013
THEME LAYER?
                1) Generation of Markup:

                ā€¢Template ļ¬les (as close to HTML as possible)
                ā€¢Preparation of data (for insertion into template ļ¬les)
                ā€¢Addition of assets (CSS + JS)
                                           Ā 




Thursday, April 11, 2013
THEME LAYER?
                2) System of complete overrides:

                ā€¢Alteration of HTML in template ļ¬les
                ā€¢Alteration of data (before insertion into templates)
                ā€¢Inclusion of additional assets     Ā 



                           (or exclusion of existing assets)




Thursday, April 11, 2013
THEME LAYER?
                3) System of partial overrides:

                ā€¢Alteration of HTML in template ļ¬les
                ā€¢Alteration of data (before insertion into templates)
                ā€¢Inclusion of additional assets     Ā 



                           (or exclusion of existing assets)

                ...but only under certain circumstances.




Thursday, April 11, 2013
DRUPAL 7 THEME LAYER
                           but, we have this now!




                                     Ā 




Thursday, April 11, 2013
DRUPAL 7 THEME LAYER
                           it looks like this (simpliļ¬ed)




                                         Ā 




Thursday, April 11, 2013
DRUPAL 7 THEME LAYER
                             it feels like this




                                     Ā 




Thursday, April 11, 2013
HARD TO LEARN


                                 Ā 




Thursday, April 11, 2013
HARD TO LEARN
                              for lots of reasons




                                       Ā 




Thursday, April 11, 2013
HARD TO LEARN
                                Mixed data types




                                         Ā 




                             String, Object or Array?

Thursday, April 11, 2013
HARD TO LEARN
                           Different methods of printing variables




                                              Ā 




                                  print or print render()?

Thursday, April 11, 2013
HARD TO LEARN
                                  Two ways to override markup:
                           TEMPLATE FILES           THEME FUNCTIONS


                                               Ā 




                                      When do I use what?

Thursday, April 11, 2013
HARD


                           Ā 
                               Too many template ļ¬les




Thursday, April 11, 2013
HARDER


                           Way too many theme functions
                              Ā 




Thursday, April 11, 2013
HARD TO LEARN
                               Insecure.




                                   Ā 




Thursday, April 11, 2013
HARD TO LEARN
                              Really, itā€™s insecure.




                                        Ā 




Thursday, April 11, 2013
HARD TO LEARN
                                  Drupal-speciļ¬c




                                        Ā 




               Drupalism noun Something that only exists in Drupal.

Thursday, April 11, 2013
HARD TO LEARN


                                        Ā 




                           too many complex subsystems

Thursday, April 11, 2013
HARD TO LEARN
                                      because

              1. Mixed data types (strings, objects & arrays)
              2. Different methods of printing variables (print, render)
              3.Two ways to override markup: templates & theme fns
                                           Ā 



              4. Too many template ļ¬les & Too many theme functions
              5. Insecure
              6. Drupal-speciļ¬c
              7. A complex mix of subsystems




Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                           Principals to guide us.




                             lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
      Core default markup should strive for semantic simplicity, with
      few HTML elements, added only as needed




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
      We won't assume we know what people want or add features
      based on "What-if...?" We will think about the 90% of use cases.




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
      Give front-end experts a way to achieve speciļ¬c goals; goals that
      apply to the remaining 10% of use cases.




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
    4. Consolidate
      Don't make something new when something common can be
      used instead. (letā€™s create a Theme Component Library).




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
    4. Consolidate
    5. Visibility
      You should be able to see what's going on without reading docs.




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
    4. Consolidate
    5. Visibility
    6. Consistency
      Do the same things everywhere, follow patterns.




                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
    4. Consolidate
    5. Visibility
    6. Consistency
    7. Don't dumb it down
      Complexity should be reduced but not obscured.



                            lb.com/twig#principles

Thursday, April 11, 2013
DRUPAL 8 THEME LAYER
                            Principals to guide us
    1. Start with nothing
    2. Build from use cases
    3. Provide tools
    4. Consolidate
    5. Visibility
    6. Consistency
    7. Don't dumb it down
    8. Organization should be driven by meaning and
    semantics over technical convenience
      Consider what an element means rather than how it
      structurally appears. Theme developers want to see markup in
      templates, not abstraction.

Thursday, April 11, 2013
A NEW THEME ENGINE?




Thursday, April 11, 2013
TWIG




                           well documented

Thursday, April 11, 2013
TWIG




                           extensible

Thursday, April 11, 2013
TWIG




                           secure

Thursday, April 11, 2013
TWIG




                            fast

Thursday, April 11, 2013
TWIG




                           IDE integration

Thursday, April 11, 2013
TWIG




                           recognizable syntax

Thursday, April 11, 2013
TWIG




                           by the creator of Symfony, Fabien Potencier

Thursday, April 11, 2013
TWIG
                           what does it look like?




Thursday, April 11, 2013
TWIG
                           what does it look like?




Thursday, April 11, 2013
TWIG
                           print with {{ }}




Thursday, April 11, 2013
TWIG
                           commands with {% %}




Thursday, April 11, 2013
TWIG
                           comments with {# #}




Thursday, April 11, 2013
TWIG
                           drill down into all variables with .




Thursday, April 11, 2013
TWIG

                           All markup is generated in template ļ¬les.




Thursday, April 11, 2013
D7 PAIN POINTS
                               does Twig help?

              1. Mixed data types
              2. Different methods of printing variables
              3.Two ways to override markup
                                        Ā 



              4. Too many template ļ¬les & theme functions
              5. Insecure
              6. Drupal-speciļ¬c
              7. A complex mix of subsystems




Thursday, April 11, 2013
D7 PAIN POINTS
                                    does Twig help?

              1. Mixed data types

                                           Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                              does Twig help?

              1. Mixed data types
                    All template variables are accessed
                                  consistently:
                                     Ā 



                                     node.nid
                                   content.links




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED

                                       Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                                   does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables
                                           Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                              does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables
               Removed calls to render() from templates:
                                     Ā 



                                   {{ node.nid }}
                                 {{ content.links }}




Thursday, April 11, 2013
D7 PAIN POINTS
                                 does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
                                         Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                                 does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup
                                         Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup
                                       Ā 



                 All theme functions become templates.
                         node.tpl.php becomes node.html.twig
                        theme_table() becomes table.html.twig




Thursday, April 11, 2013
D7 PAIN POINTS
                                 does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                         Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                                 does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                         Ā 



              4. Too many template ļ¬les & theme functions




Thursday, April 11, 2013
D7 PAIN POINTS
                                 does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                         Ā 



              4. Too many template ļ¬les & theme functions
                      Weā€™re working on this right now




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure
               All variables are *automatically* sanitized
                           and most PHP functions
                   cannot be executed in template ļ¬les.



Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c
                     Twig is used elsewhere on the web
                is syntactically similar to other languages
                       and looks a lot more like HTML.


Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c FIXED




Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c FIXED
              7. A complex mix of subsystems




Thursday, April 11, 2013
D7 THEME LAYER




Thursday, April 11, 2013
D8 IMPROVEMENTS




                           remove theme functions (and overrides) entirely.

Thursday, April 11, 2013
D8 IMPROVEMENTS




                               remove process.

Thursday, April 11, 2013
D8 IMPROVEMENTS




                               remove render.

Thursday, April 11, 2013
D8 IMPROVEMENTS




                               remove page alter?

Thursday, April 11, 2013
D9 IMPROVEMENTS




                              remove preprocess?

Thursday, April 11, 2013
D7 PAIN POINTS
                               does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                      Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c FIXED
              7. A complex mix of subsystems
              We can remove all theme functions, render,
                     process & (maybe) preprocess too.


Thursday, April 11, 2013
D7 PAIN POINTS
                                does Twig help?


              1. Mixed data types FIXED
              2. Different methods of printing variables FIXED
              3.Two ways to override markup FIXED
                                       Ā 



              4. Too many template ļ¬les & theme functions @todo
              5. Insecure FIXED
              6. Drupal-speciļ¬c FIXED
              7. A complex mix of subsystems @todo




Thursday, April 11, 2013
D7 PAIN POINTS
                             does Twig help?




                                    Ā 




Thursday, April 11, 2013
D7 PAIN POINTS
                             does Twig help?
                                  YES!!!


                                    Ā 




Thursday, April 11, 2013
TWIG: OTHER WINS




Thursday, April 11, 2013
TWIG: OTHER WINS
                            less code than PHP functions




Thursday, April 11, 2013
TWIG: OTHER WINS
                               less code than PHP functions
                                                                 D7




                                                                 D8


                           theme_image becomes image.html.twig
Thursday, April 11, 2013
TWIG
                                  less code than PHP functions

                                                   D7




         D8




                           theme_username becomes username.html.twig
Thursday, April 11, 2013
TWIG
                            less code than PHP functions




                                                               D7

    D8




                           theme_link becomes link.html.twig
Thursday, April 11, 2013
D7

                                lots less code than PHP functions


                                                               D8




                                     theme_item_list becomes
                                        item_list.html.twig
Thursday, April 11, 2013
TWIG: OTHER WINS
                             Awesome template inspection.




Thursday, April 11, 2013
TWIG: OTHER WINS
                             Awesome template inspection.




                               (ā€œdevel themerā€ in core)

Thursday, April 11, 2013
TWIG: OTHER WINS
                             Awesome variable inspection.




Thursday, April 11, 2013
TWIG: OTHER WINS
                             Awesome variable inspection.




                                (develā€™s dpm() in core)

Thursday, April 11, 2013
TWIG: OTHER WINS
                               Template inheritance




Thursday, April 11, 2013
TWIG: OTHER WINS
                                  Template inheritance




                            comment-wrapper.html.twig before

Thursday, April 11, 2013
TWIG: OTHER WINS
                                 Template inheritance




                            comment-wrapper.html.twig after

Thursday, April 11, 2013
TWIG: OTHER WINS
                                  Template inheritance




                            comment-wrapper--forum.html.twig
                                    (child template)
Thursday, April 11, 2013
TWIG: OTHER WINS
                           Possible performance gains (Much TBD)




Thursday, April 11, 2013
TWIG: OTHER WINS
                           Possible performance gains (Much TBD)

               ā€¢ PHPtemplate reads ļ¬les from disk on every use
                 (or stat()s them with APC)
               ā€¢ Twig templates are read once & compiled into classes




Thursday, April 11, 2013
TWIG: OTHER WINS
                           Possible performance gains (Much TBD)

               ā€¢ PHPtemplate reads ļ¬les from disk on every use
                 (or stat()s them with APC)
               ā€¢ Twig templates are read once & compiled into classes
               Rendering should get much faster when the same
               content element appears multiple times on the page.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           Possible performance gains (Much TBD)

               ā€¢ PHPtemplate reads ļ¬les from disk on every use
                 (or stat()s them with APC)
               ā€¢ Twig templates are read once & compiled into classes
               Rendering should get much faster when the same
               content element appears multiple times on the page.

               Consolidating many similar templates will result in an
               additional gain.


Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing ļ¬nally safe.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing ļ¬nally safe.


                ā€¢ Saving PHP code in the database is a HUGE no-no.
                ā€¢ Twig is not PHP, and is safe to store!




Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing ļ¬nally safe.


                ā€¢ Saving PHP code in the database is a HUGE no-no.
                ā€¢ Twig is not PHP, and is safe to store!
                Modules like ā€˜Contemplateā€™ (Content templates) will
                ļ¬nally be safe to use.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing ļ¬nally safe.


                ā€¢ Saving PHP code in the database is a HUGE no-no.
                ā€¢ Twig is not PHP, and is safe to store!
                Modules like ā€˜Contemplateā€™ (Content templates) will
                ļ¬nally be safe to use.

                In-browser template editing is something WordPress
                users have been asking of Drupal for a very long time.



Thursday, April 11, 2013
TWIG: OTHER WINS
                   Twig template ļ¬les can be used on the front end, too.




Thursday, April 11, 2013
TWIG: OTHER WINS
                   Twig template ļ¬les can be used on the front end, too.

     One template can return markup for both your PHP-generated
       pages, as well as pages generated vi JS in AJAX callbacks.




Thursday, April 11, 2013
TWIG: OTHER WINS
                   Twig template ļ¬les can be used on the front end, too.

     One template can return markup for both your PHP-generated
       pages, as well as pages generated vi JS in AJAX callbacks.

                      We can use other open source libraries like TwigJS.
                           (https://github.com/schmittjoh/twig.js)




Thursday, April 11, 2013
TWIG: OTHER WINS
                           2-way communication between UI and code.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           2-way communication between UI and code.


                                        No broken UIs.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           2-way communication between UI and code.


                                        No broken UIs.

     Template ļ¬les can be created ļ¬rst, and the Drupal site can build
      itself* based on the presence and location of variables in the
                                templates.




                                         *within reason

Thursday, April 11, 2013
THE NEW THEME LAYER
          IN DRUPAL 8
                           looks pretty awesome, right?




Thursday, April 11, 2013
QUESTIONS?

Thursday, April 11, 2013
HELP US GET THERE
                                  we need your help!

                            we could be ā€œdoneā€ in 1.5 weeks

                             http://drupal.org/node/1757550

                                   IRC: #drupal-twig




Thursday, April 11, 2013
THE NEW THEME LAYER
          IN DRUPAL 8
                           Jen Lampton ~ @jenlampton
                               www.jenlampton.com




Thursday, April 11, 2013
photo credits:
                                                                                  lolcat-ļ¬‚exible
                                                                      http://cheezburger.com/2679924736

                                                                           anything is possible pebbles
                                                                   http://www.invergordontours.com/aip.html

                                                                                lolcat questionmark
                                                                http://icanhascheezburger.com/2007/10/31/11197/

                                                                               wheel-reinvented
                                         http://www.brainwads.net/drewhawkins/2012/01/dont-re-invent-the-wheel-make-something-better/

                                                                                      objects
                                                        http://2teachers1classroom.blogspot.com/2009_02_01_archive.html

                                                                                         shapes
                                                         http://englishclass.jp/reading/topic/For_Screening_Purposes_Only

                                                                                       secure
                                                           http://blog.stratepedia.org/2010/06/03/what-is-a-secure-site/

                                                                                     consistency
                                                       http://icsigns.org/press/2010/03/23/consistency-staying-on-the-mark/

                                                                                 twig bird comic
              http://s302.photobucket.com/albums/nn105/walkseva/?action=view&current=thebirdneedsthattwig.gif&currenttag=bird%20park%20twig%20comic%20need%20it

                                                                               twig docs screenshots
                                                                     http://twig.sensiolabs.org/documentation

                                                                                twig speed graphs
                                                                            http://phpcomparison.net/

                                                                                    python icon
                                                                            http://python-hosting.org/

                                                                                     ruby icon
                                                                         http://itmediaconnect.ro/en/web

                                                                                    django logo
                                                           http://py-arahat.blogspot.com/2010/08/django-vs-pylons.html

                                                                                   symfony logo
                                                                             http://symfony.com/logo

                                                                                   scotch glass
                                                               http://www.thespir.it/articles/scotch-101/?viewall=1

                                                                                 speech bubble
                                               http://ljtfash.blogspot.com/2012/10/youre-beautiful-no-matter-what-they-say.html


Thursday, April 11, 2013

More Related Content

Viewers also liked

Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
Benoit Marchant
Ā 
The Wonderful World of Drupal 8 Multilingual
The Wonderful World of Drupal 8 MultilingualThe Wonderful World of Drupal 8 Multilingual
The Wonderful World of Drupal 8 Multilingual
Suzanne Dergacheva
Ā 
Paragraphs at drupal 8.
Paragraphs at drupal 8.Paragraphs at drupal 8.
Paragraphs at drupal 8.
Anatoliy Polyakov
Ā 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
Jay Friendly
Ā 
Drupal 8 override: services and plugins
Drupal 8 override: services and pluginsDrupal 8 override: services and plugins
Drupal 8 override: services and plugins
Anton Ivanov
Ā 
Drupal 8 - A Brief Introduction
Drupal 8 - A Brief IntroductionDrupal 8 - A Brief Introduction
Drupal 8 - A Brief Introduction
Jeff Geerling
Ā 
Agriculture connectƩe 4.0
Agriculture connectƩe 4.0Agriculture connectƩe 4.0
Agriculture connectƩe 4.0
JƩrƓme Monteil
Ā 

Viewers also liked (7)

Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
Ā 
The Wonderful World of Drupal 8 Multilingual
The Wonderful World of Drupal 8 MultilingualThe Wonderful World of Drupal 8 Multilingual
The Wonderful World of Drupal 8 Multilingual
Ā 
Paragraphs at drupal 8.
Paragraphs at drupal 8.Paragraphs at drupal 8.
Paragraphs at drupal 8.
Ā 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
Ā 
Drupal 8 override: services and plugins
Drupal 8 override: services and pluginsDrupal 8 override: services and plugins
Drupal 8 override: services and plugins
Ā 
Drupal 8 - A Brief Introduction
Drupal 8 - A Brief IntroductionDrupal 8 - A Brief Introduction
Drupal 8 - A Brief Introduction
Ā 
Agriculture connectƩe 4.0
Agriculture connectƩe 4.0Agriculture connectƩe 4.0
Agriculture connectƩe 4.0
Ā 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
Ā 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
Ā 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
Ā 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
Ā 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
Ā 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
Ā 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
UiPathCommunity
Ā 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
Ā 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
Ā 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
Ā 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
Ā 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
Ā 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
Ā 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
Ā 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
Ā 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
Ā 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
Ā 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Ā 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
Ā 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Ā 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ā 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Ā 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
Ā 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Ā 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
Ā 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Ā 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Ā 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
Ā 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Ā 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
Ā 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ā 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
Ā 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Ā 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Ā 

Twig & the new theme layer in Drupal 8

  • 1. THE NEW THEME LAYER IN DRUPAL 8 Jen Lampton Thursday, April 11, 2013
  • 2. JEN LAMPTON @jenlampton on twitter ā€œjenlamptonā€ http://drupal.org/user/85586 www.jenlampton.com Ā  if you forget my name, just Google ā€œDrupal developerā€ Thursday, April 11, 2013
  • 3. MY BACKGROUND Ā  Building websites since 1997 Thursday, April 11, 2013
  • 4. MY BACKGROUND Ā  Working with Drupal since 2006 Thursday, April 11, 2013
  • 5. MY BACKGROUND Ā  Consider myself a developer. Thursday, April 11, 2013
  • 6. MY BACKGROUND Ā  Also a Drupal trainer. Thursday, April 11, 2013
  • 7. MY BACKGROUND Ā  Accidental Drupal 8 ā€œinitiativeā€ leader. Thursday, April 11, 2013
  • 8. MY ā€œINITIATIVEā€ (unofļ¬cial) Ā  Thursday, April 11, 2013
  • 9. MY ā€œINITIATIVEā€ (unofļ¬cial) Ā  A new theme layer for Drupal 8 Thursday, April 11, 2013
  • 10. THEME LAYER? 1) Generation of Markup: ā€¢Template ļ¬les (as close to HTML as possible) ā€¢Preparation of data (for insertion into template ļ¬les) ā€¢Addition of assets (CSS + JS) Ā  Thursday, April 11, 2013
  • 11. THEME LAYER? 2) System of complete overrides: ā€¢Alteration of HTML in template ļ¬les ā€¢Alteration of data (before insertion into templates) ā€¢Inclusion of additional assets Ā  (or exclusion of existing assets) Thursday, April 11, 2013
  • 12. THEME LAYER? 3) System of partial overrides: ā€¢Alteration of HTML in template ļ¬les ā€¢Alteration of data (before insertion into templates) ā€¢Inclusion of additional assets Ā  (or exclusion of existing assets) ...but only under certain circumstances. Thursday, April 11, 2013
  • 13. DRUPAL 7 THEME LAYER but, we have this now! Ā  Thursday, April 11, 2013
  • 14. DRUPAL 7 THEME LAYER it looks like this (simpliļ¬ed) Ā  Thursday, April 11, 2013
  • 15. DRUPAL 7 THEME LAYER it feels like this Ā  Thursday, April 11, 2013
  • 16. HARD TO LEARN Ā  Thursday, April 11, 2013
  • 17. HARD TO LEARN for lots of reasons Ā  Thursday, April 11, 2013
  • 18. HARD TO LEARN Mixed data types Ā  String, Object or Array? Thursday, April 11, 2013
  • 19. HARD TO LEARN Different methods of printing variables Ā  print or print render()? Thursday, April 11, 2013
  • 20. HARD TO LEARN Two ways to override markup: TEMPLATE FILES THEME FUNCTIONS Ā  When do I use what? Thursday, April 11, 2013
  • 21. HARD Ā  Too many template ļ¬les Thursday, April 11, 2013
  • 22. HARDER Way too many theme functions Ā  Thursday, April 11, 2013
  • 23. HARD TO LEARN Insecure. Ā  Thursday, April 11, 2013
  • 24. HARD TO LEARN Really, itā€™s insecure. Ā  Thursday, April 11, 2013
  • 25. HARD TO LEARN Drupal-speciļ¬c Ā  Drupalism noun Something that only exists in Drupal. Thursday, April 11, 2013
  • 26. HARD TO LEARN Ā  too many complex subsystems Thursday, April 11, 2013
  • 27. HARD TO LEARN because 1. Mixed data types (strings, objects & arrays) 2. Different methods of printing variables (print, render) 3.Two ways to override markup: templates & theme fns Ā  4. Too many template ļ¬les & Too many theme functions 5. Insecure 6. Drupal-speciļ¬c 7. A complex mix of subsystems Thursday, April 11, 2013
  • 28. DRUPAL 8 THEME LAYER Principals to guide us. lb.com/twig#principles Thursday, April 11, 2013
  • 29. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing Core default markup should strive for semantic simplicity, with few HTML elements, added only as needed lb.com/twig#principles Thursday, April 11, 2013
  • 30. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases We won't assume we know what people want or add features based on "What-if...?" We will think about the 90% of use cases. lb.com/twig#principles Thursday, April 11, 2013
  • 31. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools Give front-end experts a way to achieve speciļ¬c goals; goals that apply to the remaining 10% of use cases. lb.com/twig#principles Thursday, April 11, 2013
  • 32. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate Don't make something new when something common can be used instead. (letā€™s create a Theme Component Library). lb.com/twig#principles Thursday, April 11, 2013
  • 33. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate 5. Visibility You should be able to see what's going on without reading docs. lb.com/twig#principles Thursday, April 11, 2013
  • 34. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate 5. Visibility 6. Consistency Do the same things everywhere, follow patterns. lb.com/twig#principles Thursday, April 11, 2013
  • 35. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate 5. Visibility 6. Consistency 7. Don't dumb it down Complexity should be reduced but not obscured. lb.com/twig#principles Thursday, April 11, 2013
  • 36. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate 5. Visibility 6. Consistency 7. Don't dumb it down 8. Organization should be driven by meaning and semantics over technical convenience Consider what an element means rather than how it structurally appears. Theme developers want to see markup in templates, not abstraction. Thursday, April 11, 2013
  • 37. A NEW THEME ENGINE? Thursday, April 11, 2013
  • 38. TWIG well documented Thursday, April 11, 2013
  • 39. TWIG extensible Thursday, April 11, 2013
  • 40. TWIG secure Thursday, April 11, 2013
  • 41. TWIG fast Thursday, April 11, 2013
  • 42. TWIG IDE integration Thursday, April 11, 2013
  • 43. TWIG recognizable syntax Thursday, April 11, 2013
  • 44. TWIG by the creator of Symfony, Fabien Potencier Thursday, April 11, 2013
  • 45. TWIG what does it look like? Thursday, April 11, 2013
  • 46. TWIG what does it look like? Thursday, April 11, 2013
  • 47. TWIG print with {{ }} Thursday, April 11, 2013
  • 48. TWIG commands with {% %} Thursday, April 11, 2013
  • 49. TWIG comments with {# #} Thursday, April 11, 2013
  • 50. TWIG drill down into all variables with . Thursday, April 11, 2013
  • 51. TWIG All markup is generated in template ļ¬les. Thursday, April 11, 2013
  • 52. D7 PAIN POINTS does Twig help? 1. Mixed data types 2. Different methods of printing variables 3.Two ways to override markup Ā  4. Too many template ļ¬les & theme functions 5. Insecure 6. Drupal-speciļ¬c 7. A complex mix of subsystems Thursday, April 11, 2013
  • 53. D7 PAIN POINTS does Twig help? 1. Mixed data types Ā  Thursday, April 11, 2013
  • 54. D7 PAIN POINTS does Twig help? 1. Mixed data types All template variables are accessed consistently: Ā  node.nid content.links Thursday, April 11, 2013
  • 55. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED Ā  Thursday, April 11, 2013
  • 56. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables Ā  Thursday, April 11, 2013
  • 57. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables Removed calls to render() from templates: Ā  {{ node.nid }} {{ content.links }} Thursday, April 11, 2013
  • 58. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED Ā  Thursday, April 11, 2013
  • 59. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup Ā  Thursday, April 11, 2013
  • 60. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup Ā  All theme functions become templates. node.tpl.php becomes node.html.twig theme_table() becomes table.html.twig Thursday, April 11, 2013
  • 61. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  Thursday, April 11, 2013
  • 62. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions Thursday, April 11, 2013
  • 63. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions Weā€™re working on this right now Thursday, April 11, 2013
  • 64. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo Thursday, April 11, 2013
  • 65. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure Thursday, April 11, 2013
  • 66. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure All variables are *automatically* sanitized and most PHP functions cannot be executed in template ļ¬les. Thursday, April 11, 2013
  • 67. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED Thursday, April 11, 2013
  • 68. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c Thursday, April 11, 2013
  • 69. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c Twig is used elsewhere on the web is syntactically similar to other languages and looks a lot more like HTML. Thursday, April 11, 2013
  • 70. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c FIXED Thursday, April 11, 2013
  • 71. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c FIXED 7. A complex mix of subsystems Thursday, April 11, 2013
  • 72. D7 THEME LAYER Thursday, April 11, 2013
  • 73. D8 IMPROVEMENTS remove theme functions (and overrides) entirely. Thursday, April 11, 2013
  • 74. D8 IMPROVEMENTS remove process. Thursday, April 11, 2013
  • 75. D8 IMPROVEMENTS remove render. Thursday, April 11, 2013
  • 76. D8 IMPROVEMENTS remove page alter? Thursday, April 11, 2013
  • 77. D9 IMPROVEMENTS remove preprocess? Thursday, April 11, 2013
  • 78. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c FIXED 7. A complex mix of subsystems We can remove all theme functions, render, process & (maybe) preprocess too. Thursday, April 11, 2013
  • 79. D7 PAIN POINTS does Twig help? 1. Mixed data types FIXED 2. Different methods of printing variables FIXED 3.Two ways to override markup FIXED Ā  4. Too many template ļ¬les & theme functions @todo 5. Insecure FIXED 6. Drupal-speciļ¬c FIXED 7. A complex mix of subsystems @todo Thursday, April 11, 2013
  • 80. D7 PAIN POINTS does Twig help? Ā  Thursday, April 11, 2013
  • 81. D7 PAIN POINTS does Twig help? YES!!! Ā  Thursday, April 11, 2013
  • 82. TWIG: OTHER WINS Thursday, April 11, 2013
  • 83. TWIG: OTHER WINS less code than PHP functions Thursday, April 11, 2013
  • 84. TWIG: OTHER WINS less code than PHP functions D7 D8 theme_image becomes image.html.twig Thursday, April 11, 2013
  • 85. TWIG less code than PHP functions D7 D8 theme_username becomes username.html.twig Thursday, April 11, 2013
  • 86. TWIG less code than PHP functions D7 D8 theme_link becomes link.html.twig Thursday, April 11, 2013
  • 87. D7 lots less code than PHP functions D8 theme_item_list becomes item_list.html.twig Thursday, April 11, 2013
  • 88. TWIG: OTHER WINS Awesome template inspection. Thursday, April 11, 2013
  • 89. TWIG: OTHER WINS Awesome template inspection. (ā€œdevel themerā€ in core) Thursday, April 11, 2013
  • 90. TWIG: OTHER WINS Awesome variable inspection. Thursday, April 11, 2013
  • 91. TWIG: OTHER WINS Awesome variable inspection. (develā€™s dpm() in core) Thursday, April 11, 2013
  • 92. TWIG: OTHER WINS Template inheritance Thursday, April 11, 2013
  • 93. TWIG: OTHER WINS Template inheritance comment-wrapper.html.twig before Thursday, April 11, 2013
  • 94. TWIG: OTHER WINS Template inheritance comment-wrapper.html.twig after Thursday, April 11, 2013
  • 95. TWIG: OTHER WINS Template inheritance comment-wrapper--forum.html.twig (child template) Thursday, April 11, 2013
  • 96. TWIG: OTHER WINS Possible performance gains (Much TBD) Thursday, April 11, 2013
  • 97. TWIG: OTHER WINS Possible performance gains (Much TBD) ā€¢ PHPtemplate reads ļ¬les from disk on every use (or stat()s them with APC) ā€¢ Twig templates are read once & compiled into classes Thursday, April 11, 2013
  • 98. TWIG: OTHER WINS Possible performance gains (Much TBD) ā€¢ PHPtemplate reads ļ¬les from disk on every use (or stat()s them with APC) ā€¢ Twig templates are read once & compiled into classes Rendering should get much faster when the same content element appears multiple times on the page. Thursday, April 11, 2013
  • 99. TWIG: OTHER WINS Possible performance gains (Much TBD) ā€¢ PHPtemplate reads ļ¬les from disk on every use (or stat()s them with APC) ā€¢ Twig templates are read once & compiled into classes Rendering should get much faster when the same content element appears multiple times on the page. Consolidating many similar templates will result in an additional gain. Thursday, April 11, 2013
  • 100. TWIG: OTHER WINS In-browser template editing ļ¬nally safe. Thursday, April 11, 2013
  • 101. TWIG: OTHER WINS In-browser template editing ļ¬nally safe. ā€¢ Saving PHP code in the database is a HUGE no-no. ā€¢ Twig is not PHP, and is safe to store! Thursday, April 11, 2013
  • 102. TWIG: OTHER WINS In-browser template editing ļ¬nally safe. ā€¢ Saving PHP code in the database is a HUGE no-no. ā€¢ Twig is not PHP, and is safe to store! Modules like ā€˜Contemplateā€™ (Content templates) will ļ¬nally be safe to use. Thursday, April 11, 2013
  • 103. TWIG: OTHER WINS In-browser template editing ļ¬nally safe. ā€¢ Saving PHP code in the database is a HUGE no-no. ā€¢ Twig is not PHP, and is safe to store! Modules like ā€˜Contemplateā€™ (Content templates) will ļ¬nally be safe to use. In-browser template editing is something WordPress users have been asking of Drupal for a very long time. Thursday, April 11, 2013
  • 104. TWIG: OTHER WINS Twig template ļ¬les can be used on the front end, too. Thursday, April 11, 2013
  • 105. TWIG: OTHER WINS Twig template ļ¬les can be used on the front end, too. One template can return markup for both your PHP-generated pages, as well as pages generated vi JS in AJAX callbacks. Thursday, April 11, 2013
  • 106. TWIG: OTHER WINS Twig template ļ¬les can be used on the front end, too. One template can return markup for both your PHP-generated pages, as well as pages generated vi JS in AJAX callbacks. We can use other open source libraries like TwigJS. (https://github.com/schmittjoh/twig.js) Thursday, April 11, 2013
  • 107. TWIG: OTHER WINS 2-way communication between UI and code. Thursday, April 11, 2013
  • 108. TWIG: OTHER WINS 2-way communication between UI and code. No broken UIs. Thursday, April 11, 2013
  • 109. TWIG: OTHER WINS 2-way communication between UI and code. No broken UIs. Template ļ¬les can be created ļ¬rst, and the Drupal site can build itself* based on the presence and location of variables in the templates. *within reason Thursday, April 11, 2013
  • 110. THE NEW THEME LAYER IN DRUPAL 8 looks pretty awesome, right? Thursday, April 11, 2013
  • 112. HELP US GET THERE we need your help! we could be ā€œdoneā€ in 1.5 weeks http://drupal.org/node/1757550 IRC: #drupal-twig Thursday, April 11, 2013
  • 113. THE NEW THEME LAYER IN DRUPAL 8 Jen Lampton ~ @jenlampton www.jenlampton.com Thursday, April 11, 2013
  • 114. photo credits: lolcat-ļ¬‚exible http://cheezburger.com/2679924736 anything is possible pebbles http://www.invergordontours.com/aip.html lolcat questionmark http://icanhascheezburger.com/2007/10/31/11197/ wheel-reinvented http://www.brainwads.net/drewhawkins/2012/01/dont-re-invent-the-wheel-make-something-better/ objects http://2teachers1classroom.blogspot.com/2009_02_01_archive.html shapes http://englishclass.jp/reading/topic/For_Screening_Purposes_Only secure http://blog.stratepedia.org/2010/06/03/what-is-a-secure-site/ consistency http://icsigns.org/press/2010/03/23/consistency-staying-on-the-mark/ twig bird comic http://s302.photobucket.com/albums/nn105/walkseva/?action=view&current=thebirdneedsthattwig.gif&currenttag=bird%20park%20twig%20comic%20need%20it twig docs screenshots http://twig.sensiolabs.org/documentation twig speed graphs http://phpcomparison.net/ python icon http://python-hosting.org/ ruby icon http://itmediaconnect.ro/en/web django logo http://py-arahat.blogspot.com/2010/08/django-vs-pylons.html symfony logo http://symfony.com/logo scotch glass http://www.thespir.it/articles/scotch-101/?viewall=1 speech bubble http://ljtfash.blogspot.com/2012/10/youre-beautiful-no-matter-what-they-say.html Thursday, April 11, 2013