Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Bought Jack McDade's course on design. Going through it now...and it is SO well done!

— Justin Jackson, Transistor.fm

macro Modifier

Macro is a very special modifier. It performs no modifications of its own, but rather lets you create reusable groups of modifiers and give them a name. Those groups are each called a "macro" and are stored in your resources/macros.yaml file. Keep in mind that the order of modifiers within a macro matter, the same way as regular modifiers.

# /resources/macros.yaml
headline:
title: true
widont: true
remove_right: .
 
# Page content
title: Actually i don't know what we're talking about.
{{ title | macro('headline') }}
{{ Statamic::modify($title)->macro('headline') }}
Actually I Don't Know What We're Talking About

When passing multiple parameters to a modifier, you'll need to pop down into a simple list:

# /resources/macros.yaml
excerpt:
safe_truncate:
- 175
- ...

This is equivalent to:

{{ content | safe_truncate(175, '...') }}
{{ Statamic::modify($content)->safeTruncate([175, '...']) }}
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →