Templating with Timber
Here’s an example from the documentation
Start by downloading the Timber starter theme available here. After installing the theme, you initialize Timber in your functions.php file
<?php
$timber = new Timber\Timber();
You’re ready to start theming!
Continuing on with their example, find the file wp-content/themes/{timber-starter-theme}/templates/single.twig
Let’s start with a simple post:
{% extends "base.twig" %}
{% block content %}
{{ post.title }}
{{ post.subtitle }}
{{ post.content }}
{% endblock %}
Which now allows us to do this
{{ post.title }}
instead of the old way which is …
<a href=””>
Way cleaner with Timber. When we get to building out content blocks, Timber looks like this
{% extends "base.twig" %}
{% block content %}
{{ post.title }}
{{ post.subtitle }}
{% endblock %}
{{ post.content }}
{% endblock %}
When you read that, you immediately know what’s happening in that section!
This is just the tip of the iceberg with Timber. Check out the documentation if you want to give it a try here.