nrueckmann / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

$smarty.block.parent (and child) can't be used as variables or function arguments #141

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using template inheratance and want to use decorator function on parent 
block's content. Something like that:

{block side_category_link}
    {$acpobj->parselinks($smarty.block.parent)}
{/block}

Smarty gives me Smarty syntax error with that code.
So I have to use (this one works fine):

{block side_category_link}
    {capture name=tmp}{$smarty.block.parent}{/capture}
    {$acpobj->parselinks($smarty.capture.tmp)}
{/block}

If I try to use this code it get's even worse (PHP syntax error) :)

{block side_category_link}
    {$acpobj->parselinks("{$smarty.block.parent}")}
{/block}
syntax error, unexpected '?'

Original issue reported on code.google.com by var...@gmail.com on 21 Jun 2013 at 7:49

GoogleCodeExporter commented 8 years ago
Currently template inheritance is processed at compile time and 
{$smarty.block.child} and {$smarty.block.parent} are not real variables, but 
place holder into which parent child block source get merged during 
compilation. 

That's why you can't use it like a variable and you must use capture as in you 
example.

This restriction will be removed in Smarty 3.2 which will be released later 
this year.

Original comment by Uwe.Tews@googlemail.com on 21 Jun 2013 at 11:02

GoogleCodeExporter commented 8 years ago
I thought so, it's ok. :) I wonder how you're going to remove this restrict in 
3.2, waiting for it! Thanks.

Original comment by var...@gmail.com on 21 Jun 2013 at 12:23