I need a suggestion to use a template engine for WordPress theme development. Right now there is no Coding Standard mentioned by WordPress for theme development with template engines. So if I use a template engine, whether WordPress approves it to be uploaded in wordpress.org
I am bit confused between the template engines Laravel's Blade and Mustache. Which one is better or is there any other better options available? Also for wp blade the WordPress version compatibility is only up to version 3.9.2
as per this link.
UPDATE
If I should not use a template engine, tell me why and I am planning in MVC design pattern. I am planning to use Sprig, does it has any performance improvement?
WordPress is a natural environment for us to see how templating engines work, not only because it's template-driven, but because of its reliance on PHP.
You can also edit templates via the Site Editor. Go to Appearance → Editor in your dashboard. You will be taken to the template your homepage uses. To switch to editing a different template, click your site icon in the upper left corner and select Templates.
The list of available templates can be found at Pages > Add New > Attributes > Template. Therefore, a WordPress user can choose any page template with a template name, which might not be your intention.
PHP is not a template engine, but a language that can be used to write templates, or template engines. A template engine is not just a language, but also the programming API that allows the scripts to locate, organize templates or assign the data from the script to them.
WordPress Custom Theme Tutorial Step #1: Creating Essential Files for Your Custom Theme. A functioning WordPress theme can consist of just two files:... Step #2: Create functions.php. Functions.php is not strictly a required file, but it provides so many benefits that 99. Step #3: Add Template ...
Templating engines are fantastic and work great with WordPress. It is purely a matter of preference as far as which one works best for your skill set and the website you are building. Sites that require lots of complex views may benefit from an engine that offers more logic in the templates like Timber or Jade.
Sage is a modern WordPress starter theme based on Gulp, Bootstrap, and Bower. It uses a Theme Wrapper which helps you avoid repeating the same code in every template. Sage is actively maintained and has a strong following among WordPress front-end developers.
Page Templates allow developers to create custom templates that can be used for individual posts and pages. For example, most themes have a two-column (content – sidebar) layout but on some pages, the user might want to just focus on the content and not show a sidebar.
Something to consider when choosing a Wordpress starter theme or framework is the community behind it. I would recommend using Timber (or the Timber Starter Theme) instead of Sprig because it is backed by a much larger community:
Sprig on Github: Last updated in Jan 29. 2 contributors
Timber on Github: Last updated yesterday. 62 contributors
Both options use the Twig templating engine.
Finally, I would caution against holding too tightly to the MVC paradigm for your Wordpress theme. Wordpress is event driven, providing action and filter hooks at each stage of the page creation process. In other words, it's more about extending what's already been provided than developing your own MVC abstractions. Here's an article on the subject. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With