-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
I created a module for myself and got frustrated how inflexible phpwcms own template language is, especially the conditional statements with [REPLACEMENT_TAG_ELSE]. I think it's time to slowly move or offer, something like Twig while keeping the "old" way intact.
This is a quick example with loading template fragments:
<!-- /tmpl.twig -->
{% if AUTHOR %}
<h1>{{ AUTHOR }}</h1>
{% endif %}// twig is included via composer/autoload.php
$twig = new \Twig_Environment(new \Twig_Loader_String());
$data = [
'AUTHOR' => 'Mark Twain',
'TITLE' => 'The Awful German Language'
];
$template = get_file_contents('tmpl.twig');
// render twig
$TMP = $twig->render($template, $data);
// old way to keep old code intact
$TMP = render_cnt_template($TMP, 'AUTHOR', $rss['item_author'] ? $rss['item_author'] : '' );I think it would help cleaning up core code too.
The only concerns I would have is performance when this is used to render every single content part and as I found out now, Twig_Loader_String is not the recommended way to load template strings: https://stackoverflow.com/questions/31081910/what-to-use-instead-of-twig-loader-string.
Thoughts?
q23