twig 输出php,php – 如何将TWIG输出渲染为变量供以后使用(symfony2)?

而不是这样渲染我的TWIG中的每个幻灯片(见第6行):

{# loop out the slides #}

{% for c in contents %}

{% set i=i+1 %} {# increase slide number #}

{# the slide itself, rendered by it's own template #}

{% include 'BizTVArchiveBundle:ContentTemplate:'~c.template~'/view.html.twig' with {'contents': c, 'ordernumber': i} %}

{% endfor %}

相反,我想把所有这些逻辑都保留在控制器中,以便将视图提供给一系列准备好的幻灯片.我该如何做这样的事情(见第9行):

//do stuff...

foreach ($container->getContent() as $c) {

$content[$i]['title'] = $c->getTitle();

$content[$i]['sort'] = $c->getSortOrder();

$content[$i]['data'] = $c->getData();

$content[$i]['template'] = $c->getTemplate()->getId();

$content[$i]['duration'] = $this->extract_seconds($c);

$content[$i]['html'] = $this->render('BizTVArchiveBundle:ContentTemplate:'.$content[$i]['template'].'/view.html.twig', array(

'contents'=> $content[$i],

'ordernumber' => 99,

));

}

所有它现在给我($content [$i] [‘html]]的内容)

{"headers":{}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值