54
A NEW THEME LAYER FOR DRUPAL 8 Morten Birch Heide-Jorgensen ~ @mortendk John Albin Wilkins ~ @johnalbin Alex Bronstein ~ @effulgentsia Kris Vanderwater ~ @eclipsegc Jen Lampton ~ @jenlampton Carl Wiedemann ~ @c4rl Tuesday, November 13, 2012

A NEW THEME LAYER FOR DRUPAL 8 · FOR DRUPAL 8 Morten Birch Heide-Jorgensen ~ @mortendk John Albin Wilkins ~ @johnalbin Alex Bronstein ~ @effulgentsia Kris Vanderwater ~ @eclipsegc

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

  • A NEW THEME LAYERFOR DRUPAL 8

    Morten Birch Heide-Jorgensen ~ @mortendk John Albin Wilkins ~ @johnalbinAlex Bronstein ~ @effulgentsiaKris Vanderwater ~ @eclipsegcJen Lampton ~ @jenlamptonCarl Wiedemann ~ @c4rl

    Tuesday, November 13, 2012

  • THE NEW THEME LAYER IN DRUPAL 8

    Tuesday, November 13, 2012

  • WHY?

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: POSITIVE

    Tuesday, November 13, 2012

  • DRUPAL 7: POSITIVE

     

    flexible

    Tuesday, November 13, 2012

  • DRUPAL 7: POSITIVE

     

    anything is possible

    Tuesday, November 13, 2012

  • DRUPAL 7: NEGATIVE

     

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    Drupalism noun Something that only exists in Drupal.

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    Object or Array?

    Tuesday, November 13, 2012

  • DRUPAL 7: NEGATIVE

     

    print or print render() ?

    Tuesday, November 13, 2012

  • DRUPAL 7: NEGATIVE

     

    PHP is insecure

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    Too many template files

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    Too many theme functions

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    complex mix of subsystems

    Tuesday, November 13, 2012

  •  

    DRUPAL 7: NEGATIVE

    Drupal 7 is too hard to learn!

    Tuesday, November 13, 2012

  •  

    THIS IS A LOT OF STUFF•Drupal-specific template conventions•Mixed data types (strings, objects & arrays)

    $node->nid vs $content[‘links’]•Different methods of printing

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure•Two ways to override markup

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions•Complex mix of subsystems•Difficult to learn for newcomers (and D6 veterans)

    Tuesday, November 13, 2012

  • DRUPAL 8

    Tuesday, November 13, 2012

  • TWIG

    well documented

    Tuesday, November 13, 2012

  • TWIG

    extensible

    Tuesday, November 13, 2012

  • TWIG

    secure

    Tuesday, November 13, 2012

  • TWIG

    well-tested

    Tuesday, November 13, 2012

  • TWIG

    fast

    Tuesday, November 13, 2012

  • TWIG

    IDE integration

    Tuesday, November 13, 2012

  • TWIG

    recognizable syntax

    Tuesday, November 13, 2012

  • TWIG

    by Symfony’s author, Fabien Potencier

    Tuesday, November 13, 2012

  • TWIGwhat does it look like?

    Tuesday, November 13, 2012

  • what does it look like?

    TWIG

    print with {{ }}

    Tuesday, November 13, 2012

  • what does it look like?

    TWIG

    commands with {% %}

    Tuesday, November 13, 2012

  • what does it look like?

    TWIG

    comments with {# #}

    Tuesday, November 13, 2012

  • what does it look like?

    TWIG

    simple and intuitive

    Tuesday, November 13, 2012

  • less code than PHP

    TWIG

    all theme functions become template files.a single way to override markup!

    Tuesday, November 13, 2012

  • TWIG

    D7

    D8

    theme_username becomes username.html.twig

    less code than PHP

    Tuesday, November 13, 2012

  • TWIG

    D7

    D8

    theme_image becomes image.html.twig

    less code than PHP

    Tuesday, November 13, 2012

  • TWIG

    D7

    D8

    theme_link becomes link.html.twig

    less code than PHP

    Tuesday, November 13, 2012

  • TWIG

    D7

    D8

    theme_item_list beomes item_list.html.twig

    less code than PHP

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions•Mixed data types (strings, objects & arrays)

    $node->nid vs $content[‘links’]•Different methods of printing

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure•Two ways to override markup

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions•Complex mix of subsystems•Difficult to learn for newcomers (and D6 veterans)

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions

    Twig is used elsewhere on the web,and looks more like HTML.

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays)

    $node->nid vs $content[‘links’]All template variables are accessed consistently:

    node.nidcontent.links

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing

    print $node->nid vs print render($content[‘links’])We’re removed calls to render() from templates:

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

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecureAll variables are automatically sanitized and PHP

    functions cannot be executed in template files.

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup

    Templates: *.tpl.php vs functions: theme_foo()All theme functions are converted to

    template filesnode.tpl.php becomes node.html.twig

    theme(‘table’) becomes table.html.twig

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions

    We’re working on this right now (Sprints!)

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems

    We can potentially remove theme functions, render, process.

    Tuesday, November 13, 2012

  • remember the complexity of Drupal 7?

    REMEMBER DRUPAL 7?

    Tuesday, November 13, 2012

  • look what would happen in Drupal 8.

    REMEMBER DRUPAL 7?

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems @todo•Difficult to learn for newcomers (and D6 veterans)

    Tuesday, November 13, 2012

  •  

    REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED

    $node->nid vs $content[‘links’]•Different methods of printing FIXED

    print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED

    Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems @todo•Difficult to learn for newcomers (and D6 veterans)

    Consistency FTW

    Tuesday, November 13, 2012

  • •Finish converting all existing core *.tpl.php files to Twig templates

    •Finish converting all existing core theme functions to Twig templates

    •Consolidate similar templates and identify template suggestions for extensibility

    •Convert renderable arrays into Twig objects

    •More TBD

    TWIG: NEXT TASKS

    Tuesday, November 13, 2012

  • •Twig template inheritance

    •Variable inspection: Twig’s dpm()

    •Possible performance gains: much TBD, faster than render()?

    •2-way communication between UI and code: The UI can understand what variables exist (or not) in a template

    TWIG: OTHER WINS

    Tuesday, November 13, 2012

  • HOW CAN I HELP?

    Tuesday, November 13, 2012

  • •Twig Sprint: Sunday in Pauley Ballroom•Convert theme functions to template files•Help create the Theme Component Library•Help clean up markup in core•More!

    Come talk to us!

    TWIG AT BADCAMP

    Tuesday, November 13, 2012

  • QUESTIONS?

    Tuesday, November 13, 2012

  • A NEW THEME LAYERFOR DRUPAL 8

    Tuesday, November 13, 2012

  • photo credits:lolcat-flexible

    http://cheezburger.com/2679924736

    anything is possible pebbleshttp://www.invergordontours.com/aip.html

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

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

    objectshttp://2teachers1classroom.blogspot.com/2009_02_01_archive.html

    shapeshttp://englishclass.jp/reading/topic/For_Screening_Purposes_Only

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

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

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

    twig docs screenshotshttp://twig.sensiolabs.org/documentation

    twig speed graphshttp://phpcomparison.net/

    python iconhttp://python-hosting.org/

    ruby iconhttp://itmediaconnect.ro/en/web

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

    symfony logohttp://symfony.com/logo

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

    Tuesday, November 13, 2012

    http://cheezburger.com/2679924736http://cheezburger.com/2679924736http://www.invergordontours.com/aip.htmlhttp://www.invergordontours.com/aip.htmlhttp://icanhascheezburger.com/2007/10/31/11197/http://icanhascheezburger.com/2007/10/31/11197/http://www.brainwads.net/drewhawkins/2012/01/dont-re-invent-the-wheel-make-something-better/http://www.brainwads.net/drewhawkins/2012/01/dont-re-invent-the-wheel-make-something-better/http://2teachers1classroom.blogspot.com/2009_02_01_archive.htmlhttp://2teachers1classroom.blogspot.com/2009_02_01_archive.htmlhttp://englishclass.jp/reading/topic/For_Screening_Purposes_Onlyhttp://englishclass.jp/reading/topic/For_Screening_Purposes_Onlyhttp://blog.stratepedia.org/2010/06/03/what-is-a-secure-site/http://blog.stratepedia.org/2010/06/03/what-is-a-secure-site/http://icsigns.org/press/2010/03/23/consistency-staying-on-the-mark/http://icsigns.org/press/2010/03/23/consistency-staying-on-the-mark/http://s302.photobucket.com/albums/nn105/walkseva/?action=view&current=thebirdneedsthattwig.gif&currenttag=bird%20park%20twig%20comic%20need%20ithttp://s302.photobucket.com/albums/nn105/walkseva/?action=view&current=thebirdneedsthattwig.gif&currenttag=bird%20park%20twig%20comic%20need%20ithttp://twig.sensiolabs.org/documentationhttp://twig.sensiolabs.org/documentationhttp://phpcomparison.net/http://phpcomparison.net/http://python-hosting.org/http://python-hosting.org/http://itmediaconnect.ro/en/webhttp://itmediaconnect.ro/en/webhttp://py-arahat.blogspot.com/2010/08/django-vs-pylons.htmlhttp://py-arahat.blogspot.com/2010/08/django-vs-pylons.htmlhttp://symfony.com/logohttp://symfony.com/logohttp://www.thespir.it/articles/scotch-101/?viewall=1http://www.thespir.it/articles/scotch-101/?viewall=1