Using Timber + Twig with Sage , Bedrock, Trellis

I’m interested in using Twig (via Timber) on a large-ish site redevelopment using WordPress.

(I’m using liquid on another project (which has a similar syntax) and saw this article, which sold me on the use of Twig in WordPress.)

I just came across Root, listened to the first podcast, and am really impressed.

I was wondering if it’s possible to add Twig and Timber to a WordPress site using Sage (& Bedrock, Trellis) without problems? Or will there be issues that will cause things to break?

Thank you

I don’t see why not, I would just give it a go.
I’m planning on trying it out too on my next project, I can see the benefits of splitting php & html markup!

1 Like

I’ve used Timber for three small projects as of late, using Roots as the starter theme and I’m very happy with the results. Utilising it in combination with Bedrock and Trellis doesn’t seem to cause any problems, though I’ve only used Bedrock+Trellis for development purposes (no staging to production servers).

I must confess, I’ve disabled Roots’ Theme Wrapper in order for Timber to be able to render the correct Twig files. Hopefully this doesn’t earn me the ire of the Roots developers. :wink: Right now my projects are a bit of mix between Roots and the Timber Starter Theme. But I would be very interested in a version of the theme that works the Theme Wrapper, if that’s at all possible.

Incidentally, the new version of Roots currently in development is rumoured to include a Yeoman generator in order for people to choose their own framework (Bootstrap, Foundation, etc.). I’ve also seen some posts regarding planned Yeoman support for Timber/Twig. This thread is interesting as well.

1 Like

:rage: :rage: :rage: :rage: :rage:

Actually that makes sense, since Twig uses it’s own router. With using Twig, I would assume you would use your own default layout anyways, which is basically all that the theme wrapper is doing - mimicking the surrounding HTML on every page, instead of a call to get_header() and get_footer()

2 Likes

[quote=“kalenjohnson, post:4, topic:5210”]
Actually that makes sense, since Twig uses it’s own router.
[/quote]Phew! :sweat_smile:

The biggest uncertainty for me is how Timber deals with third-party plugins using frontend templates. I haven’t run in to problems using a few popular plugins and the Timber documentation presents WooCommerce, one of the more complex plugins around, as a possible starting point to use third-party plugins. The Timber Starter Theme does some extra stuff in the header.php and footer.php to accommodate plugins with templates.

But as for the combination Timber with Roots: it’s great and a fine addition to an already awesome toolset.

Did just port the latest Sage version to Timber. Hope this helps.

2 Likes

@artifex404 thanks for making this, it’s exactly what i was looking for. just forked a copy to exchange gulp & bower for webpack and npm for yarn. let me know if that’s something you’d ever want to incorporate in the original

In my case I just need Timber for the helper classes, since Sage 9 uses Laravel Blades, Twig is not needed anymore. You can just use Timber without rendering.