在树枝中初始化功能?

时间:2017-11-20 09:56:24

标签: php twig

如何在.twig文件中初始化函数?

localhost/firstAngularProject

该功能如何成为.twig格式? 像那样:

<?php function renderCategories($categories, $selected, $button_edit, $column_sort_order, $column_name, $column_action) { ?>
    function body..
<?php } ?>

但是如何设置功能结束?

1 个答案:

答案 0 :(得分:3)

最佳解决方案恕我直言是创建一个

L = [(x, list(i)) for x, y in df[['Type','list_dates']].values 
                  for i in list(itertools.combinations(y,2))]

定义宏后,您可以使用它:

{# macros.html.twig #}
{% macro renderCategories(categories, selected, button_edit, column_sort_order, column_name, column_action) %}
{# then here goes the body of your macro HTML and loops... #}
{% endmacro %}

在此处详细了解宏:https://twig.symfony.com/doc/2.x/tags/macro.html