A presentation at WordCamp Norway 2014 in January 2014 in Oslo, Norway by Andrey Savchenko
2 Andrey “Rarst” Savchenko • Rarst.net ♦ WPSE ( s.tk/wp ) • QueryPosts.com • Composer.Rarst.net
Why would I need another templating engine when PHP is already one?
Why would I need another programming language when PHP is already one?
5 WordPress theme dev is more than PHP 1. template hierarchy 2. template tags API
nana nana nana nana nana nana nana nana [gallery] !
7 “ Innovation in WordPress templating is dead WordPress look, you know? • get_template_part() — in WP 3.0 (2010) • theme wrappers — around WP 3.2 (2011) Nothing in last 3 years & 8 major releases
8 Featuritis cheat sheet • sandboxing • default escape • template inheritance
9 Abstractions Protect you from code. Constraints Protect you from yourself.
11 Mustache — entry to templates & facial hair 1. context 2. “logic-less” template mustache.github.io
12 Mustache — example {{#posts}} <li>{{post_title}}</li> {{/posts}} {{^posts}} <li>No posts</li> {{/posts}}
13 Twig — pack leader of PHP templating 1. context 2. loader (lexer, parser, compiler) 3. template (filters, functions, macros, and more) twig.sensiolabs.org
14 Twig — example {% for post in posts %} <li>{{post.post_title}}</li> {% else %} <li>No posts</li> {% endfor %}
15 Timber — WordPress + Twig 1. context in PHP template 2. Twig template 3. OOP context access API timber.upstatement.com
16 Timber — example {% for post in posts %} <li>{{post.title}}</li> {% else %} <li>No posts</li> {% endfor %}
17 Meadow — WordPress templating DSL 1. template hierarchy 2. template tags API 3. DSL API bitbucket.org/rarst/meadow
18 Meadow — example {% loop %} <li>{{ the_title() }}</li> <!-@TODO {% else %} <li>No posts</li> --> {% endloop %}
Are my templating needs being met with adequate tools?
20 Burst the bubble! Questions? • @Rarst • The Loop ( s.tk/chat ) Rarst.net/slides/templating