Search code examples
phptemplatessmartydwoo

Is there anything like Dwoo-s {with} or {loop} in Smarty 3 or earlier?


{with} and {loop} plugins in Dwoo template engine change default context for variable name resolution.

If in Dwoo you feed template:

{$arr.foo}
{with $arr} {$foo} / {$arr.foo} {/with}

with data:

array('arr' => array( 'foo' => 'bar' ))

it will output:

bar
bar / 

because second {$arr.foo} actually means {$arr.arr.foo} in global context.

Do you know how can I achieve similar effect in Smarty?

Is there some builit in functionality or third party plugin that might allow me to have this?

Do you have any idea how to build such a plugin if it does not exist?


Solution

  • To my knowledge you can't achieve this effect in Smarty 3 or earlier.