Question

{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?

Was it helpful?

Solution 2

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

OTHER TIPS

You have foreach to achive the loop:

{foreach from=$arr item=foo}
    <li>{$foo}</li>
{/foreach}

If you are however searching for a replacement of with, I'm afraid there is no similar command in Smarty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top