SlideShare uma empresa Scribd logo
1 de 89
DRUPAL 8
TEMPLATING WITH
TWIG
DRUPAL 7: POSITIVE
flexible
DRUPAL 7: POSITIVE
unified~ish data structures everywhere
DRUPAL 7: POSITIVE
anything is possible
DRUPAL 7: NEGATIVE
Drupal only (weird) syntax
DRUPAL 7: NEGATIVE
Object or Array?
DRUPAL 7: NEGATIVE
print or print render()?
DRUPAL 7: NEGATIVE
PHP is insecure
DRUPAL 7: NEGATIVE
PHP is insecure
DRUPAL 7: NEGATIVE
Too many template files
DRUPAL 7: NEGATIVE
Too many theme functions
DRUPAL 7: NEGATIVE
complex mix of subsystems
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 fns
5. Insecure
6. Drupal-specific
7. A complex mix of subsystems
DRUPAL 8 THEME LAYER
let’s fix it
Accidental Drupal 8 “initiative” leader
DRUPAL 8 THEME LAYER
Principals to guide us
1. Start with nothing
DRUPAL 8 THEME LAYER
Principals to guide us
1. Start with nothing
2. Build from use cases
DRUPAL 8 THEME LAYER
Principals to guide us
1. Start with nothing
2. Build from use cases
3. Provide tools
DRUPAL 8 THEME LAYER
Principals to guide us
1. Start with nothing
2. Build from use cases
3. Provide tools
4. Consolidate
DRUPAL 8 THEME LAYER
Principals to guide us
1. Start with nothing
2. Build from use cases
3. Provide tools
4. Consolidate
5. Visibility
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
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
TWIG
well documented
TWIG
extensible
TWIG
secure
TWIG
fast
TWIG
IDE integration
TWIG
recognizable syntax
TWIG
by Symfony’s author, Fabien Potencier
TWIG
print with {{ }}
TWIG
commands with {% %}
TWIG
comments with {# #}
D7 PAIN POINTS
does Twig help?
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 fns
5. Insecure
6. Drupal-specific
7. A complex mix of subsystems
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays)
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays)
All template variables are accessed
consistently:
node.nid
content.links
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables (print, render)
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables (print, render)
Removed calls to render() from
templates:
{{ node.nid }}
{{ content.links }}
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) 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
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme
We’re working on this right now
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure
All variables are *automatically* sanitized
and most PHP functions
cannot be executed in template files.
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
6. Drupal-specific
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @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.
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
6. Drupal-specific FIXED
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
6. Drupal-specific FIXED
7. A complex mix of subsystems
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
6. Drupal-specific FIXED
7. A complex mix of subsystems
D7 THEME LAYER
D8 IMPROVEMENTS
remove theme functions (and overrides) entirely
D8 IMPROVEMENTS
remove process.
D8 IMPROVEMENTS
remove render.
D8 IMPROVEMENTS
remove page alter?
D9 IMPROVEMENTS
remove preprocess?
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @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.
D7 PAIN POINTS
does Twig help?
1. Mixed data types (strings, objects & arrays) FIXED
2. Different methods of printing variables FIXED
3. Two ways to override markup FIXED
4. Too many template files & Too many theme @todo
5. Insecure FIXED
6. Drupal-specific FIXED
7. A complex mix of subsystems @todo
D7 PAIN POINTS
does Twig help?
YES!!!
TWIG: OTHER WINS
less code than PHP functions
D7
D8
theme_image becomes image.html.twig
TWIG: OTHER WINS
less code than PHP functions
theme_username becomes username.html.twig
D7
D8
TWIG: OTHER WINS
less code than PHP functions
theme_link becomes link.html.twig
D7
D8
TWIG: OTHER WINS
lots less code than PHP functions
theme_item_list becomes
item_list.html.twig
D7
D8
TWIG: OTHER WINS
Awesome template inspection
(“devel themer” in core)
TWIG: OTHER WINS
Awesome variable inspection
(devel’s dpm() in core)
TWIG: OTHER WINS
Template inheritance
comment-wrapper.html.twig before
TWIG: OTHER WINS
Template inheritance
comment-wrapper.html.twig after
TWIG: OTHER WINS
Template inheritance
comment-wrapper--forum.html.twig
(child template)
TWIG: OTHER WINS
Possible performance gains (Much TBD)
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
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.
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.
TWIG: OTHER WINS
In-browser template editing finally safe.
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!
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.
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.
TWIG: OTHER WINS
Twig template files can be used on the front end, too.
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.
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)
TWIG: OTHER WINS
2-way communication between UI and code.
TWIG: OTHER WINS
2-way communication between UI and code.
No broken UIs.
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
D8 THEME ENGINE PROFILING
WARMING OF TWIG IN D8
14%
86%
Yes
No
HOT THEMES
FontFolioZURB Foundation
ZURB Foundation
http://g.ua/WrKG
Links
1. Theming Drupal 8
2. Twig documentation (RU)
3. Twig coding standards
4. DrupalCon Portland 2013: USING TWIG: THE
NEW TEMPLATE ENGINE IN DRUPAL 8
Ask me
Taras Omelianenko
CEO
+380 97 508 84 74
Skype: taras.omelyanenko
t.omelianenko@dicslab.com
www.dicslab.com

Mais conteúdo relacionado

Mais procurados

Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeAdolfo Nasol
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entitiesdrubb
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep diveRomain Jarraud
 
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Laura Scott
 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)kuydigital
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & Moredrubb
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingRobert Carr
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Emma Jane Hogbin Westby
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Eugenio Minardi
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Emma Jane Hogbin Westby
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Formsdrubb
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceAimee Maree Forsstrom
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Moduledrubb
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comtutorialsruby
 

Mais procurados (17)

Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 Theme
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep dive
 
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & More
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
Oop's in php
Oop's in php Oop's in php
Oop's in php
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)
 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritence
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Module
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
 
Oops in php
Oops in phpOops in php
Oops in php
 

Semelhante a Drupal 8 templating with twig

Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Twig in the wild august 2018 drupal govcon draft
Twig in the wild   august 2018 drupal govcon draftTwig in the wild   august 2018 drupal govcon draft
Twig in the wild august 2018 drupal govcon draftJeremyKoulish
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Rene Bakx
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend developmentsparkfabrik
 
What “Model” DITA Specializations Can Teach About Information Modelinc
What “Model” DITA Specializations Can Teach About Information ModelincWhat “Model” DITA Specializations Can Teach About Information Modelinc
What “Model” DITA Specializations Can Teach About Information ModelincDon Day
 
Being Dangerous with Twig
Being Dangerous with TwigBeing Dangerous with Twig
Being Dangerous with TwigRyan Weaver
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixStefan Krawczyk
 
Rupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritanceRupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritancerupicon
 
Dita ot pipeline webinar
Dita ot pipeline webinarDita ot pipeline webinar
Dita ot pipeline webinarSuite Solutions
 
Themer's roundtable
Themer's roundtableThemer's roundtable
Themer's roundtablecanarymason
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Acquia
 
Being Dangerous with Twig (Symfony Live Paris)
Being Dangerous with Twig (Symfony Live Paris)Being Dangerous with Twig (Symfony Live Paris)
Being Dangerous with Twig (Symfony Live Paris)Ryan Weaver
 
Designing Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsDesigning Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsAVEVA
 
Building Drupal 8 Sites
Building Drupal 8 SitesBuilding Drupal 8 Sites
Building Drupal 8 SitesExove
 
Introduction To Information Modeling With DITA
Introduction To Information Modeling With DITAIntroduction To Information Modeling With DITA
Introduction To Information Modeling With DITAScott Abel
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem UnsolvedSchalk Cronjé
 

Semelhante a Drupal 8 templating with twig (20)

Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Twig in the wild august 2018 drupal govcon draft
Twig in the wild   august 2018 drupal govcon draftTwig in the wild   august 2018 drupal govcon draft
Twig in the wild august 2018 drupal govcon draft
 
Open source Technology
Open source TechnologyOpen source Technology
Open source Technology
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
What “Model” DITA Specializations Can Teach About Information Modelinc
What “Model” DITA Specializations Can Teach About Information ModelincWhat “Model” DITA Specializations Can Teach About Information Modelinc
What “Model” DITA Specializations Can Teach About Information Modelinc
 
A forest of designs without subthemes
A forest of designs without subthemesA forest of designs without subthemes
A forest of designs without subthemes
 
Being Dangerous with Twig
Being Dangerous with TwigBeing Dangerous with Twig
Being Dangerous with Twig
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch Fix
 
T4 presentation
T4 presentationT4 presentation
T4 presentation
 
Rupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritanceRupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritance
 
Dita ot pipeline webinar
Dita ot pipeline webinarDita ot pipeline webinar
Dita ot pipeline webinar
 
Themer's roundtable
Themer's roundtableThemer's roundtable
Themer's roundtable
 
Drupal 6 Theming
Drupal 6 ThemingDrupal 6 Theming
Drupal 6 Theming
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
 
Being Dangerous with Twig (Symfony Live Paris)
Being Dangerous with Twig (Symfony Live Paris)Being Dangerous with Twig (Symfony Live Paris)
Being Dangerous with Twig (Symfony Live Paris)
 
Designing Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsDesigning Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio Projects
 
Building Drupal 8 Sites
Building Drupal 8 SitesBuilding Drupal 8 Sites
Building Drupal 8 Sites
 
Introduction To Information Modeling With DITA
Introduction To Information Modeling With DITAIntroduction To Information Modeling With DITA
Introduction To Information Modeling With DITA
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem Unsolved
 

Último

Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory:  summary 2024IoT Insurance Observatory:  summary 2024
IoT Insurance Observatory: summary 2024Matteo Carbone
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menzaictsugar
 
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCRashishs7044
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationAnamaria Contreras
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailAriel592675
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCRashishs7044
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...ShrutiBose4
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfJos Voskuil
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessSeta Wicaksana
 
8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCRashishs7044
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCRashishs7044
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfrichard876048
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaoncallgirls2057
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMintel Group
 
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby AfricaKenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africaictsugar
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncrdollysharma2066
 

Último (20)

Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory:  summary 2024IoT Insurance Observatory:  summary 2024
IoT Insurance Observatory: summary 2024
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
 
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement Presentation
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
 
Call Us ➥9319373153▻Call Girls In North Goa
Call Us ➥9319373153▻Call Girls In North GoaCall Us ➥9319373153▻Call Girls In North Goa
Call Us ➥9319373153▻Call Girls In North Goa
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
 
8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdf
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 Edition
 
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby AfricaKenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
 

Drupal 8 templating with twig

  • 3. DRUPAL 7: POSITIVE unified~ish data structures everywhere
  • 5. DRUPAL 7: NEGATIVE Drupal only (weird) syntax
  • 7. DRUPAL 7: NEGATIVE print or print render()?
  • 10. DRUPAL 7: NEGATIVE Too many template files
  • 11. DRUPAL 7: NEGATIVE Too many theme functions
  • 12. DRUPAL 7: NEGATIVE complex mix of subsystems
  • 13. 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 fns 5. Insecure 6. Drupal-specific 7. A complex mix of subsystems
  • 14. DRUPAL 8 THEME LAYER let’s fix it Accidental Drupal 8 “initiative” leader
  • 15. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing
  • 16. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases
  • 17. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools
  • 18. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate
  • 19. DRUPAL 8 THEME LAYER Principals to guide us 1. Start with nothing 2. Build from use cases 3. Provide tools 4. Consolidate 5. Visibility
  • 20. 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
  • 21. 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
  • 28. TWIG by Symfony’s author, Fabien Potencier
  • 32. D7 PAIN POINTS does Twig help? 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 fns 5. Insecure 6. Drupal-specific 7. A complex mix of subsystems
  • 33. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays)
  • 34. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) All template variables are accessed consistently: node.nid content.links
  • 35. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED
  • 36. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables (print, render)
  • 37. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables (print, render) Removed calls to render() from templates: {{ node.nid }} {{ content.links }}
  • 38. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED
  • 39. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup
  • 40. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) 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
  • 41. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED
  • 42. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme
  • 43. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme We’re working on this right now
  • 44. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure
  • 45. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure All variables are *automatically* sanitized and most PHP functions cannot be executed in template files.
  • 46. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED
  • 47. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED 6. Drupal-specific
  • 48. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @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.
  • 49. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED 6. Drupal-specific FIXED
  • 50. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED 6. Drupal-specific FIXED 7. A complex mix of subsystems
  • 51. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED 6. Drupal-specific FIXED 7. A complex mix of subsystems
  • 53. D8 IMPROVEMENTS remove theme functions (and overrides) entirely
  • 58. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @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.
  • 59. D7 PAIN POINTS does Twig help? 1. Mixed data types (strings, objects & arrays) FIXED 2. Different methods of printing variables FIXED 3. Two ways to override markup FIXED 4. Too many template files & Too many theme @todo 5. Insecure FIXED 6. Drupal-specific FIXED 7. A complex mix of subsystems @todo
  • 60. D7 PAIN POINTS does Twig help? YES!!!
  • 61. TWIG: OTHER WINS less code than PHP functions D7 D8 theme_image becomes image.html.twig
  • 62. TWIG: OTHER WINS less code than PHP functions theme_username becomes username.html.twig D7 D8
  • 63. TWIG: OTHER WINS less code than PHP functions theme_link becomes link.html.twig D7 D8
  • 64. TWIG: OTHER WINS lots less code than PHP functions theme_item_list becomes item_list.html.twig D7 D8
  • 65. TWIG: OTHER WINS Awesome template inspection (“devel themer” in core)
  • 66. TWIG: OTHER WINS Awesome variable inspection (devel’s dpm() in core)
  • 67. TWIG: OTHER WINS Template inheritance comment-wrapper.html.twig before
  • 68. TWIG: OTHER WINS Template inheritance comment-wrapper.html.twig after
  • 69. TWIG: OTHER WINS Template inheritance comment-wrapper--forum.html.twig (child template)
  • 70. TWIG: OTHER WINS Possible performance gains (Much TBD)
  • 71. 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
  • 72. 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.
  • 73. 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.
  • 74. TWIG: OTHER WINS In-browser template editing finally safe.
  • 75. 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!
  • 76. 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.
  • 77. 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.
  • 78. TWIG: OTHER WINS Twig template files can be used on the front end, too.
  • 79. 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.
  • 80. 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)
  • 81. TWIG: OTHER WINS 2-way communication between UI and code.
  • 82. TWIG: OTHER WINS 2-way communication between UI and code. No broken UIs.
  • 83. 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
  • 84. D8 THEME ENGINE PROFILING
  • 85. WARMING OF TWIG IN D8 14% 86% Yes No
  • 88. Links 1. Theming Drupal 8 2. Twig documentation (RU) 3. Twig coding standards 4. DrupalCon Portland 2013: USING TWIG: THE NEW TEMPLATE ENGINE IN DRUPAL 8
  • 89. Ask me Taras Omelianenko CEO +380 97 508 84 74 Skype: taras.omelyanenko t.omelianenko@dicslab.com www.dicslab.com