Introduction
Channels
Templates
Contacts
Messages
API

Macros

A macro is just a little templating function you can reuse everywhere you want!

In Notifuse you can create pages of macros, and use them in your notifications templates & campaigns.

Get bored to inline your css in your HTML emails? use a macro!

Usage

Let's go directly with an example:


  {% macro paragraph(text) %}
    <p style="font-size: 20px; line-height: 26px; margin: 0 0 16px;">{{text|safe}}</p>
  {% endmacro %}

  {# Usage: #}
  {{ paragraph("I'm an HTML paragraph...") }}
  

In the above example we declare a paragraph macro that takes a "text" argument, and wraps this text around an HTML <p></p> with some styles. We also use the safe filter to be able to inject some HTML in our text, otherwise the template engine would escape it.

You can also provide default values to the parameters of your macro. Example with a default color:


  {% macro title(text, color="#00AFEC") %}
    <h2 style="color: {{color}}; line-height: 30px; margin: 0 0 12px;">{{text}}</h2>
  {% endmacro %}
    
We recommend you to create a macro for every reusable pieces of your templates: header, titles, paragraph, buttons, footer... This way your templates will stay clean and you will just have to update the macro to update all your templates!

Next: Import, sync & update your contacts ยป