<?= $lies ?>, <?= $damned['lies'] ?>,
and
no need for
{{ templating.engine }}
Andrey “Rarst” Savchenko
Why would I need another
templating engine
when PHP is already one?
Why would I need another
programming language
when PHP is already one?
WordPress theme dev is more than PHP
- template hierarchy
- template tags API
nana nana nana nana
nana nana nana nana
[gallery] !
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
Featuritis cheat sheet
- sandboxing
- default escape
- template inheritance
Abstractions
Protect you from code.
Constraints
Protect you from yourself.
Mustache — entry to templates & facial hair
- context
- “logic-less” template
mustache.github.io
Mustache — example
{{#posts}}
<li>{{post_title}}</li>
{{/posts}}
{{^posts}}
<li>No posts</li>
{{/posts}}
Twig — pack leader of PHP templating
- context
- loader (lexer, parser, compiler)
- template (filters, functions, macros, and more)
twig.sensiolabs.org
Twig — example
{% for post in posts %}
<li>{{post.post_title}}</li>
{% else %}
<li>No posts</li>
{% endfor %}
Timber — WordPress + Twig
- context in PHP template
- Twig template
- OOP context access API
timber.upstatement.com
Timber — example
{% for post in posts %}
<li>{{post.title}}</li>
{% else %}
<li>No posts</li>
{% endfor %}
Meadow — WordPress templating DSL
- template hierarchy
- template tags API
- DSL API
bitbucket.org/rarst/meadow
Meadow — example
{% loop %}
<li>{{ the_title() }}</li>
{% endloop %}
Are my
templating needs
being met with
adequate tools?