简体   繁体   English

Symfony 3在宏中使用宏?

[英]Symfony 3 using a macro in a macro?

i want to use a macro in a macro. 我想在宏中使用宏。 But how is this working? 但这如何工作?

  1. macro in my twig: 我的树枝中的宏:

      {% import _self as formSubmacros %} {% macro printSubcategoriesRow(SubcategoriesForm) %} <div class="the content of the subcatecories"> </div> {% endmacro %} 
  2. macro i write just under the first and here i want to get the 1 macro in: 我在第一个宏下面编写宏,在这里我想在其中获得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 %} 

But this is not working... 但这不起作用...

You should put the import into your macro, to get the proper scope. 您应该将import放入宏,以获取适当的范围。 If this is not working, please provide the error message 如果这不起作用,请提供错误消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM