Skip to content
A collection of useful Craft CMS macros and components.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
components
macros
CHANGELOG.md
LICENSE.md
README.md

README.md

Craft CMS Macros and Components

A collection of Craft CMS macros and components I frequently use on projects. Feel free to use, alter and extend. Suggestions are welcome.

How to use macros

I usually set the macro include in a first level template like _router.html from where I delegated all my pages and set macrosas a parameter on includes:

{# _router.html or another first level template #}
{% set macros = 'partials/_/_macros.html' %}
{% set notfound = '404' %}

{% include ['pages/' ~ entry.type.handle, notfound] with { macros: macros } %}

In the page template I just import the macros and inherit it to the components:

{# page.html #}
{% import macros as helper %}

{# Macro: macros/include.twig #}
{{helper.include('modules', 'hero', {
	image: entry.image.one() ?? null,
	macros: macros
})}}

The _macros.html or .twig:

{% macro myMacro(param) %}
{# Do something here #}
{% endmacro %}

License

Itsa MIT!

You can’t perform that action at this time.