SlideShare une entreprise Scribd 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”
                                (unofficial)




                                      




Thursday, April 11, 2013
MY “INITIATIVE”
                                (unofficial)




                                      




       A new theme layer for Drupal 8

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

                •Template files (as close to HTML as possible)
                •Preparation of data (for insertion into template files)
                •Addition of assets (CSS + JS)
                                            




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

                •Alteration of HTML in template files
                •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 files
                •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 (simplified)




                                          




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 files




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-specific




                                         




               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 files & Too many theme functions
              5. Insecure
              6. Drupal-specific
              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 specific 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 files.




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 files & theme functions
              5. Insecure
              6. Drupal-specific
              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 files & 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 files & 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 files & 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 files & 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 files & theme functions @todo
              5. Insecure
               All variables are *automatically* sanitized
                           and most PHP functions
                   cannot be executed in template files.



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 files & 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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific




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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific
                     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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific 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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific 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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific 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 files & theme functions @todo
              5. Insecure FIXED
              6. Drupal-specific 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 files 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 files 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 files 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 finally safe.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing finally 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 finally 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
                finally be safe to use.




Thursday, April 11, 2013
TWIG: OTHER WINS
                           In-browser template editing finally 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
                finally 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 files can be used on the front end, too.




Thursday, April 11, 2013
TWIG: OTHER WINS
                   Twig template files 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 files 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 files can be created first, 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-flexible
                                                                      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

Contenu connexe

En vedette

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
 

En vedette (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
 

Dernier

Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 

Dernier (20)

Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 

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” (unofficial)   Thursday, April 11, 2013
  • 9. MY “INITIATIVE” (unofficial)   A new theme layer for Drupal 8 Thursday, April 11, 2013
  • 10. THEME LAYER? 1) Generation of Markup: •Template files (as close to HTML as possible) •Preparation of data (for insertion into template files) •Addition of assets (CSS + JS)   Thursday, April 11, 2013
  • 11. THEME LAYER? 2) System of complete overrides: •Alteration of HTML in template files •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 files •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 (simplified)   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 files 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-specific   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 files & Too many theme functions 5. Insecure 6. Drupal-specific 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 specific 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 files. 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 files & theme functions 5. Insecure 6. Drupal-specific 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 files & 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 files & 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 files & 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 files & 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 files & theme functions @todo 5. Insecure All variables are *automatically* sanitized and most PHP functions cannot be executed in template files. 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 files & 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files & theme functions @todo 5. Insecure FIXED 6. Drupal-specific 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 files 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 files 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 files 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 finally safe. Thursday, April 11, 2013
  • 101. TWIG: OTHER WINS In-browser template editing finally 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 finally 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 finally be safe to use. Thursday, April 11, 2013
  • 103. TWIG: OTHER WINS In-browser template editing finally 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 finally 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 files can be used on the front end, too. Thursday, April 11, 2013
  • 105. TWIG: OTHER WINS Twig template files 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 files 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 files can be created first, 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-flexible 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