Symfony 3在宏中使用宏?

问题描述 投票:1回答:1

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

  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 %}

但这不起作用......

symfony macros twig
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.