smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.22k stars 701 forks source link

Smarty5: {config_load config variables not available in all templates #993

Closed blaaat closed 2 months ago

blaaat commented 3 months ago

Consider the following files:

test.cfg:

test="Hi"

test.html

{include file='test2.html'}

{#test#}-test.html

test2.html

{config_load file='test.cfg' scope='parent'}
{#test#}-test2.html

test.php

$smarty->display('test.html');

Smarty4 output:

Hi-test2.html
Hi-test.html

Smarty5 output:

Hi-test2.html
-test.html

Also with scope='global' in config_load this case is not working.

Is it supposed to be like this? (and should I call config_load in every template that uses the variables? or is this inefficient?)

blaaat commented 3 months ago

In the changelog this change is mentioned, but in the docs the scope is still there.

https://smarty-php.github.io/smarty/stable/designers/language-builtin-functions/language-function-config-load/#attributes