timber / timber

Create WordPress themes with beautiful OOP code and the Twig Template Engine
https://timber.github.io/docs/
MIT License
5.52k stars 513 forks source link

Force Timber to use Twig 2.x? #1673

Closed gsalkin closed 6 years ago

gsalkin commented 6 years ago

Is there a way to pass a flag or force Timber to use Twig 2.x? My installation with Timber 1.7 continues to use Twig 1.34.1. Would like to take advantage of some new features in the latest version of the templating language.

jarednova commented 6 years ago

@gsalkin this feels like a composer thing. Based on my tests, composer will use Twig 2.x when you install on > PHP 7.1. How are you installing?

gsalkin commented 6 years ago

The initial install was via composer but updates are via WordPress admin. I can re-install via composer but I'm running PHP 7.0.x. That a problem?

jarednova commented 6 years ago

@gsalkin ahhhh, that makes sense. I think what happened is you had things right at first, but then WP.org over-writes with its version (which I keep low to help people still on PHP 5.x). You should be able to do a fresh install and get Twig 2.x since you're running PHP 7 (and yes PHP 7.0 should be okay).

I brings up a good Q for people who install via Composer. Should we allow upgrades via the WP Admin?

gsalkin commented 6 years ago

@jarednova Ideally we'd all be using Composer, right? But several clients see an update for Timber and run the update via WP Admin. I'd recommend removing Timber upgrades from WP Admin.

A possible goal for #1617 and future version of 2.x would be creating parity between Composer and WP Admin installs (announce users must have >= 7.0 installed on their servers). However, most Timber users would be more advanced and already have a Composer workflow.

jarednova commented 6 years ago

Good note @gsalkin — I created #1688 as a future to-do (always open to PRs for anyone who wants to take a stab at it)

gchtr commented 6 years ago

@gsalkin Out of curiosity: When you install Timber through Composer, why did you decide to install it the plugins folder? We always install Timber as a dependency of the theme, so that it’s not listed in the plugins list, exactly because we want to update Timber through Composer and not through WordPress updates. Timber is often tightly coupled to the theme. Updating it through WordPress could break the theme, because WordPress plugin updates don’t care about semantic versioning.

I’m just thinking, is this something that we should recommend in the installation guide (not to install Timber in the plugins folder if it’s installed through Composer) and as a fallback have the check for how Timber was installed and then block updates for Composer installs? Doesn’t the plugin option exist for developers who are not familiar with Composer or don’t want to work with it?

benfurfie commented 6 years ago

@gchtr It’s considered best practice that nothing functional goes in the theme. Functionality = plugin / form = theme. Although arguably Timber - being a templating layer - could fall under the idea of theme functionality.

I typically use Bedrock which has support for muplugins. I almost always put Timber in the mu-plugins folder which keeps it away from the theme, but also out of the reach of users.

gsalkin commented 6 years ago

@gchtr I'm more concerned about the lack of parity between the plugin and the composer versions. The lack of Twig 2.x support in the plugin seems to be of a higher priority for future updates.