Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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!

About

A collection of useful Craft CMS macros and components.

Topics

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.