Symfony 3在宏中使用宏?

时间:2017-12-21 06:32:25

标签: symfony macros twig

我想在宏中使用宏。但这是如何运作的?

    我的树枝上的
  1. 宏:

        {% import _self as formSubmacros %}
    
    {% macro printSubcategoriesRow(SubcategoriesForm) %}
        <div class="the content of the subcatecories">
    
        </div>
    {% endmacro %}
    
  2. 宏我在第一个下写,我想在这里得到1个宏:

        {% import _self as formMacros %}
    
    {% macro printCategoriesRow(CategoriesForm) %}
        <div class="the content of the categories with the macro subcategories">
    
    
    
                {% for SubcategoriesForm in CategoriesForm.subcategories %}
                    {{ formSubmacros.printSubcategoriesRow(SubcategoriesForm) }}
                {% endfor %}
    
    
    
        </div>
    {% endmacro %}
    
  3. 但这不起作用......

1 个答案:

答案 0 :(得分:0)

您应该将import放入宏中,以获得适当的范围。如果这不起作用,请提供错误消息