<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ákos Resch on Medium]]></title>
        <description><![CDATA[Stories by Ákos Resch on Medium]]></description>
        <link>https://medium.com/@akosresch?source=rss-cdf8f84f051e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DKA0RwFDPbiVIJM5.png</url>
            <title>Stories by Ákos Resch on Medium</title>
            <link>https://medium.com/@akosresch?source=rss-cdf8f84f051e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:03:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akosresch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[WordPress + Twig review]]></title>
            <link>https://medium.com/@akosresch/wordpress-twig-review-d1e9cec40392?source=rss-cdf8f84f051e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1e9cec40392</guid>
            <dc:creator><![CDATA[Ákos Resch]]></dc:creator>
            <pubDate>Tue, 07 Jul 2015 15:09:04 GMT</pubDate>
            <atom:updated>2015-07-07T15:09:04.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*-5u1nxwkkxMfZ0vT.jpg" /></figure><p>I’ve used this technology on some sites and could even make it as a development standard in the company I work for. Sadly we had to let it go, so here is a review of my experiences about it!</p><h3>Why have I chosen this path?</h3><p>Well, the first and most important thing was that the company I work for wanted to use <a href="http://bit.ly/1GJbj7N">Drupal 8</a> in the future. I’m sure you know that it’s based on <a href="http://bit.ly/1LcfMAQ">Symfony 2</a> which is using the <a href="http://bit.ly/1J0vO0g">Twig</a> templating engine. Twig is an amazing templating engine, due to it’s ease of use, understanding and extension. Also it’s pretty intelligent unlike mustache or handlebars.</p><h3>What was the result of using it?</h3><p>I managed to see WordPress from an absolutely different perspective! I’ve got a better view of of the shortcode system. I also saw that I can create well structured code and clean views in WordPress. It’s because Twig forces us to do that by being able to only use variables and function calls. It leads us to create clean views, which also forces us to create <em>“controllers”</em>. While doing this never ending circle, you’ll get used to use an MVC like architecture in WordPress, which you normally totally deny when you open a WordPress code. It also prepares you to use site specific plugins to separate the logic even more and achieve clean, <em>presentation only</em> themes.</p><h3>Why I had to leave it?</h3><p>Because of a few smaller problems and two huge! The first one is the internationalisation. Of course everything could be made multilingual, so is Twig. The main problem is: <a href="http://bit.ly/1QAgoEh">WPML</a> the best, biggest, most famous plugin for creating multilingual WordPress sites: just can’t handle it. If that’s not enough: even <a href="http://bit.ly/1IGw7KT">Poedit</a>, the ultimate <em>*.po</em> editor can’t handle Twig files. There are two ways to force it:</p><ol><li>Comment a PHP opening tag at the beginning of all <em>*.twig</em> files.</li><li>Force the Python parser to parse <em>*.twig</em> files. It’ll throw a bunch of errors, but you’ll get what you want.</li></ol><p>Eww.. Gross! After you’re done with that, you can push WPML to use the <em>*.po</em> and <em>*.mo</em> files. Sounds great and your client is happy that he or she can translate these via <em>String translation</em>, but he or she can’t. WPML wouldn’t be able to replace your strings like it would normally do.</p><p>Another big issue is: portability. We create clean and beautiful code, and that’s great! But what if we have to hand over your work to someone else? You cannot be sure that this person have ever heard about or even used Twig. So he’ll look dumb, when he wants to change the PHP templates and found nothing but a rendering method. Also we can’t expect that he will learn how to use this amazing templating engine!</p><p>Finally, Twig doesn’t work out-of-the-box! You must include a library called <a href="http://bit.ly/1Ca4x3C">Timber</a> into your project. It’ll make Twig work and gives you a bunch of custom filters, functions and data conversions you’ll be able to use Twig in the WordPress system. It implements many functions of the WordPress core, but if you don’t find what you’re looking for, than you can use a wrapper function which can call every function in the system.</p><p>I have to mention that Timber is such a good library that I suggest to use it even if you don’t want to use Twig! It makes clearer <em>WP_Query</em>s, can handle images pretty good.</p><h3>Conclusion</h3><p>It was absolutely worth to try it in a few projects. It served me a bunch of useful information and experience both in programming and sitebuilding. It’s a great thing to pair WordPress and Twig, because it forces us to have a desire for the clean code, and don’t let us create shitty themes and plugins.</p><p>So as a quick summary: when it comes to plugins and themes, it’s a pretty good choice to use Twig. Also great for interns, who haven’t really seen well structured code. Sadly I got a project which relies heavily on internationalisation. With my current experience in WordPress and the chosen plugin I used I can’t fix it, so as a result I had to rewrite it in pure PHP</p><p><em>Originally published at </em><a href="https://akosresch.wordpress.com/2015/07/04/wordpress-and-twig-review/"><em>akosresch.wordpress.com</em></a><em> on July 4, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1e9cec40392" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>