Because WordPress is awesome but the loop isn't.

One of the building blocks of our starter theme is Timber. Timber brings modern templates to Wordpress. We like it so much we have incorporated it into our workflow for all new WP projects.

Timber enables you to 

  • Separate out your logic from your presentation code. 
  • Access your WP data through clear  Object orientated methods
  • write clear maintainable routes

Timber then enables you to build your site in clean easy to maintain & understand Twig templates & gives you full control of your markup.

What's Twig?

Twig is a modern template engine for PHP. Written by Fabien Portencier as part of the Symphony Framework it is a modern, well tested & well thought out template language.

Although PHP is kind-of a template language itself, it has travelled a very long way from those roots. Twig provides a much better authoring environment. Twig is more concise, has better syntax, provides features like inheritance, blocks etc. Twig also provides better security than plain PHP templates. For anyone used to modern web development from Rails, Laravel or Symphony Twig will seem familiar & welcome. And thats just over PHP.

What else does Timber do for me?

WP templating takes PHP's verbose, mildly unpleasant template syntax and adds some truly hideous practices. Traditional WP development can be frustrating to say the least. Markup in functions, overriding functions to set image size and (shudder) the loop.

Timber relieves all that by exposing WP's data in an object orientated way to your Twig templates & providing WP specific filters to easily do things that you do all day in a beautifully intuitive, unobtrusive way.

For example, resizing images:

<img src="{{post.thumbnail.src|resize(200,300)}}" />

If you don't think that is a huge improvement on the old way...

$thumb_id = get_post_thumbnail_id($post->ID);
$url = wp_get_attachment_url($thumb_id);
<img src="<?php echo $url; ?>"  />

...then we are not going to be able to get along : )

So I have to throw everything in the bin?

Nope. One of the things that attracted us to Timber over other WP - Twig integrations is that you can use as much or as little as you like. We started by using it when an area of a site needed fixing & modifying & then when new sites came up we built them 100% on timber as part of kindling. Nice easy learning curve.

What sites are running Timber?

Some sites from around the world being developed with Timber
Developed by upstatement (the authors of Timber) in partnership with some of the industries leading front end developers.
Timber smells of fine mahogany., &
Designed & built here at kindleman.


Timber Wp -
Twig -