T
T
Taras Serevann2016-04-15 10:01:28
Template Engines
Taras Serevann, 2016-04-15 10:01:28

Which templating engine to use in WordPress?

If, for example, I want to take the risk of writing a WordPress plugin using OOP, what is the best template engine to use for displaying various menus, etc.? Not directly to sculpt HTML in PHP.
Or is there some way to OOP in WP that allows you to use standard templates nicely?
I would like to know how to do it right.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2016-04-15
@Taras_Serevann

twig
but in general, you can use whatever template engine you want in your code.

T
trevoga_su, 2016-04-15
@trevoga_su

Not directly sculpt HTML in PHP
why not ?

I
Igor Vorotnev, 2016-04-15
@HeadOnFire

If you are writing for yourself/client - use whatever. However, any template engine will give you its own overhead, I see no reason to use it - WordPress has its own template engine. Yes, it's not OPP, it's not MVC, it causes a lot of pain for many, but nevertheless it is there, it is well integrated with the whole core and it works great. If your religion does not allow you to "sculpt HTML directly into PHP" - use Laravel with a blade, why did you take WordPress at all.
If you are writing a plugin for distribution (paid for Codecanyon, free for WordPress.org) - then use a native templating engine and don't complicate people's lives. Any WP developer already knows how to work with native templates, template functions, and so on. Don't force it to deal with your bikes (even if it's a well-known Twig-type templating engine). Look how WooCommerce implemented - in the plugin folder there is a folder with templates, and there is a function for connecting templates, which first checks if there is a similar template in the theme folder. This way developers can easily override your templates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question