Skip to content
Docs
/
Advanced
/
Markdown in variables

Markdown in variables

⚠️In most cases, you do not need this! Make sure you read careful consideration

Pre-formatted variables

When making use of the {{ }} syntax to add data to contacts, you can use markdown syntax to pre-format the output. If you for example want to store a list in a variable and want it to be formatted as a bulleted list when being delivered, you can do the following:

const res = await fetch('https://api.useplunk.com/v1', {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer API_KEY",
    },
    body: JSON.stringify({
        "event": "new-project",
        "email": "hello@useplunk.com",
         "data": {
            "table": "| header | header |\n|--------|--------|\n| cell   | cell   |"
         }
    }),
});

If you then use the {{table}} variable in a template, it will be automatically formatted as a table.

# My new template

{{table}}

Careful consideration

The preferred way is to use markdown in the template itself, using markdown in the data parameter should only be used for markdown that cannot be formatted in the template itself.

For example, if you want a variable to be formatted as bold text. Wrap the variable in ** and ** inside the template and it will be formatted as bold text automatically.

**{{variable}}**

Valid use cases for markdown in the data parameter

  • Tables
  • Ordered lists

Invalid use cases for markdown in the data parameter

Last updated on August 27, 2022