opencart / opencart

A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.
https://www.opencart.com/
Other
7.44k stars 4.83k forks source link

[4.0.2.3] error {% include 'my.twig' %} in editor theme #14183

Open BuslikDrev opened 5 days ago

BuslikDrev commented 5 days ago

error {% include 'my.twig' %} in editor theme

system/library/template/twig.php search $loader = new \Twig\Loader\ArrayLoader([$file => $code]); replace $loader = new \Twig\Loader\ChainLoader([new \Twig\Loader\ArrayLoader([$file => $code]), $this->loader]);

mhcwebdesign commented 5 days ago

You should really sort out your theme. There shouldn't be a need for {% include ... %} tags. Symfony Twig already is bad as is, and shouldn't have controller logic in it.

punitkumar commented 4 days ago

A Theme author must be aware and avoid using {% include ... %} tags. in Opencart context.

osworx commented 4 days ago

A Theme author must be aware and avoid using {% include ... %} tags. in Opencart context.

While I fully agree with @mhcwebdesign , may I ask why includes should be avoided? OpenCart is since the beginning full of repetitions (not only at the theme, also with language variables which leads to a lot of useless MB in the package which could be avoided), so why should a theme not use include to load a piece of theme which is used in several places?

mhcwebdesign commented 2 days ago

Template repetitions are usually a sign of a poor overall design, and should be resolved by creating a separate controller and template.

Quite a lot of Symfony Twig's functions and tags should be removed and become part of the controller or model logic. A template engine should be limited to template rendering, initiated by the controller with a given set of variables.

Symfony Twig uses a horrible syntax, as is, copied from Django and Python, it has no clear LALR syntax design.