Using Twig as rendering system
for your
Joomla extensions
by Roberto Segura
https://github.com/phproberto/joomla-twig
https://github.com/CatPointer/mod_catpointer_articles
Roberto Segura
● I’m from Spain.
● Dad of 3.
● I write PHP & Javascript.
● Freelance.
● Joomla! contributor.
● Open Source all the things!
@phprobertohttp://www.phproberto.com
What is Twig?
● Template engine.
● Used by other PHP projects.
● Easy to learn.
● Fast.
● Extensible.
● Secure.
● Unit Tested.
● Documented.
Twig features
● Variables.
● Custom tags.
● Functions.
● Filters.
● Macros.
● Inheritance.
● Clean error messages.
● Syntax highlighting.
With Twig Joomla! will:
● Remove lines of code & docs.
● Give more power to developers.
● Give more flexibility to site builders.
● Keep Backward Compatibility.
● Ease integration of external PHP devs.
● Reduce learning curve to use Joomla
(module chromes, positions..).
What about JLayout?
/layouts/joomla/form/renderfield.php
vs
● Both can live together.
● Stop using JLayout was
the original plan.
● JLayout can be used
inside Twig.
Is it hard to integrate?
https://github.com/phproberto/joomla-twig
It’s already done!
joomla-twig is:
Integration is 1 line of code!
● Opensource.
● Free.
● Extendable with plugins.
● Fully tested.
● Integrated with Joomla updates.
● Easy to integrate.
Component layout
It will search for templates in:
● templates/{template}/html/com_users/login/default.html.twig
● components/com_users/views/login/default.html.twig
Module layout
It will search for templates in:
● templates/{template}/html/mod_menu/default.html.twig
● modules/mod_menu/tmpl/default.html.twig
Library layout
It will search for templates in:
● templates/{template}/html/libraries/phproberto/default.html.twig
● libraries/phproberto/layouts/default.html.twig
Plugin layout
It will search for templates in:
● templates/{template}/html/plugins/content/joomla/default.html.twig
● plugins/content/joomla/tmpl/default.html.twig
Template layout
It will search for templates in:
● templates/{template}/html/default.html.twig
Template layout
It will search for templates in:
● templates/{template}/html/default.html.twig
Questions?

Using twig as rendering system for your Joomla extensions

  • 1.
    Using Twig asrendering system for your Joomla extensions by Roberto Segura https://github.com/phproberto/joomla-twig https://github.com/CatPointer/mod_catpointer_articles
  • 2.
    Roberto Segura ● I’mfrom Spain. ● Dad of 3. ● I write PHP & Javascript. ● Freelance. ● Joomla! contributor. ● Open Source all the things! @phprobertohttp://www.phproberto.com
  • 3.
    What is Twig? ●Template engine. ● Used by other PHP projects. ● Easy to learn. ● Fast. ● Extensible. ● Secure. ● Unit Tested. ● Documented.
  • 4.
    Twig features ● Variables. ●Custom tags. ● Functions. ● Filters. ● Macros. ● Inheritance. ● Clean error messages. ● Syntax highlighting.
  • 5.
    With Twig Joomla!will: ● Remove lines of code & docs. ● Give more power to developers. ● Give more flexibility to site builders. ● Keep Backward Compatibility. ● Ease integration of external PHP devs. ● Reduce learning curve to use Joomla (module chromes, positions..).
  • 6.
    What about JLayout? /layouts/joomla/form/renderfield.php vs ●Both can live together. ● Stop using JLayout was the original plan. ● JLayout can be used inside Twig.
  • 7.
    Is it hardto integrate? https://github.com/phproberto/joomla-twig It’s already done!
  • 8.
    joomla-twig is: Integration is1 line of code! ● Opensource. ● Free. ● Extendable with plugins. ● Fully tested. ● Integrated with Joomla updates. ● Easy to integrate.
  • 9.
    Component layout It willsearch for templates in: ● templates/{template}/html/com_users/login/default.html.twig ● components/com_users/views/login/default.html.twig
  • 10.
    Module layout It willsearch for templates in: ● templates/{template}/html/mod_menu/default.html.twig ● modules/mod_menu/tmpl/default.html.twig
  • 11.
    Library layout It willsearch for templates in: ● templates/{template}/html/libraries/phproberto/default.html.twig ● libraries/phproberto/layouts/default.html.twig
  • 12.
    Plugin layout It willsearch for templates in: ● templates/{template}/html/plugins/content/joomla/default.html.twig ● plugins/content/joomla/tmpl/default.html.twig
  • 13.
    Template layout It willsearch for templates in: ● templates/{template}/html/default.html.twig
  • 14.
    Template layout It willsearch for templates in: ● templates/{template}/html/default.html.twig
  • 15.