WordPress.org

Ready to get started?Download WordPress

Forums

Twig for template system? (5 posts)

  1. dyrer
    Member
    Posted 11 months ago #

    recently i visited drupal and read about upcoming Drupal 8 version and the adoption of Twig for template system.
    I wonder WordPress can adopt also a new template system more secure and more efficient ?

    ps. there is a plugin that helps make themes with Twig
    ps. If theme dev know twig make their life easier because they can create templates for WordPress but also Drupal

  2. jarednova
    Member
    Posted 11 months ago #

    Hey Dryer, check out:

    http://wordpress.org/plugins/timber-library/

    ... does exactly what I think you're looking for. I think if we get usage on a plugin like this we can get momentum on getting ideas like this into core.

  3. Stefano Cecere
    Member
    Posted 7 months ago #

    fully agree.. we should spread the word about using a good template engine (and Twig is the best, today), and start splitting logic (should go into plugins only) from layouts (themes, Twig or PHP powered)

  4. MikeShaw217
    Member
    Posted 6 months ago #

    I've written TwigPress, a plugin that allows you to use Twig within your WordPress themes. I've used it on a number of production sites

    Ok, marketing speel over (sorry about that!)

    You can find it here: http://wordpress.org/plugins/twigpress/

    Please let me know what you think, any questions let me know! I'm keen for templating in WordPress themes to take off as well!

    Mike

  5. NumberKruncher
    Member
    Posted 5 months ago #

    @MikeShaw217 : Thanks for the link to this!

    I wrote the following in the review, but I will echo it here since it might be interesting/relevant to future readers of this thread.

    One thing which I immediately changed when I installed this plugin into my website was the location of the Twig installation since I intend to use the composer module manager.

    I also modified the path of the "twigs" folder so that it is taken from the root of the website rather than the active theme folder. Agreed, this is counter-intuitive for the needs of most people, but my reasoning will be explained in a moment.

    Here is the directory structure which I decided go with:

    /httpdocs/blog/wp-content/plugins/twigpress/*
    /httpdocs/blog/wp-content/themes/mytheme/*
    /httpdocs/vendor/twig/twig/lib/Twig
    /httpdocs/twigs

    One of the things which I like about using Twig in this way is that it allows me to reuse the same overall site templates outside of WordPress. My website makes use of several separate systems which previously had their own separate themes/templates/skins. Twig allows me to define one master layout which each of these systems can easily share for one consistent look throughout the entire website!

    Thanks!!

Reply

You must log in to post.

About this Topic