小编Sim*_*eon的帖子

包含具有多个参数的Twig

有没有办法包含一个带有多个参数的Twig模板?

我试过这个,但它不起作用:

我的Symfony控制器呈现以下Twig:

{% for object in objects %}
        {% if object.type == "simple" %}
               {% include 'BBLWebBundle:content:simple.html.twig' 
                with [{'picture': object.picture}, {'link': object.link}, {'name': object.name}, {'info': object.info}] %}

        {% elseif object.type == "mp3" %}
                {% include 'BBLWebBundle:content:mp3.html.twig'
                with [{'picture': object.picture}, {'link': object.link}, {'name': object.name}, {'info': object.info}] %}

        {% elseif object.type == "video" %}
                {% include 'BBLWebBundle:content:video.html.twig' 
                with [{'picture': object.picture}, {'link': object.link}, {'name': object.name}, {'info': object.info}] %}
        {% endif %}
{% endfor %}    
Run Code Online (Sandbox Code Playgroud)

Controller还传递了一些参数(这只是一些Dummy-Data):

    $objects['ob1']['type'] = "simple";
    $objects['ob1']['picture'] = "this is …
Run Code Online (Sandbox Code Playgroud)

arrays parameters include twig

15
推荐指数
1
解决办法
3万
查看次数

标签 统计

arrays ×1

include ×1

parameters ×1

twig ×1