craft helper
1.0.0
我经常在项目上使用的工艺CMS宏和组件的集合。随意使用,更改和扩展。欢迎建议。
我通常将宏包含在第一个级模板中,例如_router.html ,我从其中委派所有页面并将macros设置为参数,包括:
{# _router.html or another first level template #}
{% set macros = ' partials/_/_macros.html ' %}
{% set notfound = ' 404 ' %}
{% include [ ' pages/ ' ~ entry . type . handle , notfound ] with { macros : macros } %}在页面模板中,我只是导入宏并将其继承到组件:
{# page.html #}
{% import macros as helper %}
{# Macro: macros/include.twig #}
{{helper. include ( ' modules ' , ' hero ' , {
image : entry . image . one () ?? null ,
macros : macros
})}} _macros.html或.twig:
{% macro myMacro( param ) %}
{# Do something here #}
{% endmacro %}ita麻省理工学院!