Smarty 版本 2,如果我捕获一个静态字符串:
{capture name=test}
a huge page or string can go here
{/capture}
我可以简单地使用 {$smarty.capture.test} 在当前模板或子模板中转储我捕获的字符串没问题
如果我尝试捕获“{foreach}”循环,例如:
{capture name=test}
{foreach item=Row from=$DataGrid.Rows name=RowsGrid}
,['{$Row.DataCells.project_name.Data}', {$Row.DataCells.approved_budget.Data}]
{/foreach}
{/capture}
我可以在当前模板中轻松使用它,例如:
{$smarty.capture.test}
并将正确的数据显示为字符串。但是,当我尝试在子模板中使用它时:
{include file='/full/path/child.tpl'}
{$smarty.capture.test}
这将导致空捕获的数据,如:
,['', ] ,['', ] ,['', ]
如果我使用 {$smarty.capture.test|var_dump} 它显示为“字符串(86)”我在这里错过了什么?