Timber 1.0 Is Now Available on WordPress.org

timber

Last week the creators of Timber, the plugin that enables WordPress theme developers to write HTML using the Twig Template Engine, released version 1.0 on WordPress.org. The plugin is active on more than 10,000 websites where theme authors have elected to keep PHP files separate from HTML. Timber is built on DRY and MVC principles to solve the problem stated in its unofficial tagline: “Because WordPress is awesome, but the_loop isn’t.”

Over the past four years, the open source project has evolved from being a starter theme to a plugin that can be added to existing themes. It is now used on thousands of websites and has 83 contributors listed on GitHub.

“In 2012 I was getting more into WordPress after doing lots of JS development with Handlebars (a JS templating language),” Timber creator Jared Novack said. “I went to WordCamp Providence to learn more about state-of-the-art WordPress ways. I remember thinking: ‘This is great, but I really miss the cleanliness of Handlebars — I wish someone would make something like that for WordPress.’ That’s when I realized, I was that someone.”

Novack was playing around with Smarty and Mustache before he finally discovered Fabien Potencier’s Twig project.

“The syntax felt so natural I almost didn’t need to read the docs (don’t worry, I did),” he said. “I realized what I needed was a way to marry Twig and WordPress, and thus: Timber was born.”

At that time Novack’s company, Upstatement, was beginning development on a big new project for Random House to enable their marketers to generate unique sites from a library of templates. This client project became Timber’s first test case.

“Originally, Timber was a parent theme, like _s. But after we completed the Random House project, I realized I wanted to apply Timber functionality to existing sites,” Novack said. “I converted it into a plugin that could be employed on existing themes which is the form it takes today.”

The plugin allows designers skilled with HTML and CSS to create themes without having extensive knowledge of PHP and WordPress functions. Timber successfully powers sites like Michael Bloomberg’s The Trace, Everytown for Gun Safety, Hotel Tonight, and the Harvard Law Review.

Timber 1.0 Puts the Project on the Path of Stability

As of Timber 1.0, developers can now include the project as a plugin or require it as a Composer dependency.

“The big news is that 1.0 represents a maturing of the platform — developers can use Timber and Twig with confidence that they’re building on top of a stable and universal platform,” Novack said.

This release sheds years of deprecated functions and methods dating back to the project’s early days in 2013. Novack said that technical and documentation debt were the biggest hurdles in getting to 1.0.

“In hindsight it’s so easy to build stuff, but so hard to build a complete system,” he said. “When Timber started it was just for me and the documentation could just live in my head. I’d add and improve stuff and then live with some of the quirks.”

As the project and its contributors grew, Novack found it difficult to keep up with the growing codebase while running his company. Bringing it to a place of maturity with up-to-date automated testing and documentation took nearly a year.

“Backwards compatibility was also a major challenge,” Novack said. “As ideas and new code got submitted, development slowed as every decision might have implications for existing users. We would deprecate features, but I was hesitant to remove things that I knew were mistakes, but that people were using.”

Developers are encouraged to read the 1.0 Upgrade Guide, as there may be additional steps required depending on how Timber is being used. This release adds a few new features but the most important change is the bulk removal of older sections of the codebase. The upgrade guide outlines all of the object properties and static methods that will need to be updated so that nothing breaks. In the future, Timber-powered themes will be easier to maintain, with fewer quirks and better-documented features.

“The key learning for me is that the ultimate ‘killer feature’ is stability and predictability,” Novack said. “When everything is organized cleanly and developers can use the things that they would intuitively expect — that’s success.”

15 Comments


  1. Timber is a great plugin. Huge props to Jared and the team. Been using it for several projects, as a matter of fact I wrote a series of Tutorials about Kick-Starting development with Twig with Timber at Tuts+ (Link: http://ahmda.ws/1VXPdFc )

    Report


    1. Perhaps it was among the many exceptions to this rule that were “grandfathered in” when they started enforcing it. ¯\_(ツ)_/¯

      Report


    2. Timber has been in the repository for almost 3 years now. This isn’t a “new” plugin by any means, this is just about it reaching a “1.0” release number.

      Report


      1. Aha. Misunderstood that. Thanks for clarifying. The plugin team rocks.

        Report


      2. What we “allow” in the repository is an ever evolving thing. It changes frequently, as needed, based on problem points and things we see on a daily basis. For example, whenever a new widget on social-media-service-x comes out, we immediately get deluged with dozens of plugins to implement said feature. After the first few, we start asking authors “how is this different than this other one?” People get surprisingly pissed off at that question. ;)

        The point is that having a dozen plugins all identical isn’t good for the directory or the users. So what we allow or disallow is subject to constant change. It’s never personal. But it always feels personal. That’s a bummer that I see no way to fix.

        Report


    3. Actually, Timber is not a framework, its a template engine.
      What you do with it is up to you though :)

      cu, w0lf.

      Report


  2. Maybe it is a god alternative for people with decent JS and low PHP knowledge, but imo, the WordPress way of teeming with PHP is a great opportunity.
    Using twig and this plugin is like making “love” with second extra condom ;)

    Report


      1. What, twigs and timber? Yes, winters can be very cold. In Canada. :)

        Report


  3. I’ve always disagreed with Timber’s unofficial motto. The Loop is one of WordPress’ most powerful features, you just have to know how to weild it.

    Report


    1. The loop is very flawed, but fundamentally it comes down to that the theming in wordpress is, at the core, flawed.

      Report


  4. OK jokes aside. Never understood anything that is alternative to the native “loop” – why replace one of the power points of WordPress?

    Report


  5. @Paul @Zulfikar: my issue with the loop is that the output of code can change based on the context it occurs in. My comfort zone is that a function should always return the same value when sent the same arguments. In the context of `the_loop` this isn’t always the case.

    I realize this is a feature, not a bug. Event-based architecture and so on and so on…

    Ditching the loop isn’t for everyone, and I realize I’m substituting one opinion for another. It’s definitely not the right approach for someone who’s trying to integrate with the wider WP ecosystem: your woos, your eventcalendarpros, your yoasts. My strong belief is that this opinion (MVC-like and a separation of PHP from HTML) makes more sense when growing a theme over time and sharing responsibilities between diff’t types of developers. Oh and not having <?php and ?> tags everywhere

    Report


  6. The strongest benefit I have gained from using twig is it’s template inheritance model. It has made it easier to modularize my template files. Twig embed takes a little while to wrap your head around, but once you do, it is powerful. http://twig.sensiolabs.org/doc/tags/embed.html

    My team works with both WordPress and Drupal. Because Drupal is adopting twig and our product applications use django, using twig creates more opportunity for both cross training and shared understanding.

    I have been keeping tabs on what the Craft CMS community is doing as they have been active in helping their community take advantage of twig.

    Report

Comments are closed.