craft helper
1.0.0
프로젝트에서 자주 사용하는 공예 CMS 매크로 및 구성 요소 모음. 자유롭게 사용, 변경 및 확장하십시오. 제안을 환영합니다.
나는 일반적으로 매크로 포함을 모든 페이지를 위임하고 macros 매개 변수로 설정 한 곳에서 _router.html 과 같은 첫 번째 레벨 템플릿에 포함합니다.
{# _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 %}ITSA MIT!