Table of Contents
- Overview
- Creating Snippets
- Inserting Snippets into Templates
- Editing Snippets
- Special Considerations
- Notes
Overview
Our Snippets feature allows you to easily re-use and manage plain text and HTML content across templates and mediums (email, SMS, push and in-app). With snippets, you can create and insert headers, footers and any content in between.
Benefits of using snippets:
- Standardization of content that is repeated across templates
- Example use cases include for headers, footers and call-to-action blocks
- This eliminates the work involved in re-creating this content with each new template
- Greater ease of updating content across templates
- Any changes made to a snippet will automatically propagate to templates that reference that snippet (including those tied to live campaigns)
Creating Snippets
To access the snippets management screen, navigate to Templates > Snippets in the left navigation bar.
Here, you'll see a screen like this:
You'll notice that we have a snippet already - "social_media". You can click on the name to launch and manage the already existing snippet. In our case, however, we want to create a new snippet.
Click "Create New Snippet..." to launch the snippet creation screen below. Fill in a snippet name and brief description.
Note: Your snippet name must be alphanumeric, and may contain spaces, dashes, underscores.
Take note of the {{ snippet "snippet name" }}
block. This is what you will insert into templates later on to render the content.
Next, enter (or copy and paste) the content that you want into the Markup window.
Warning: Avoid using HTML markup (use plain text instead) if intending to use a snippet with SMS, push or in-app templates.
Note: The Markup window will appear like below if you have the WYSIWYG editor enabled in the project settings.
Regardless of the editor that you're using, you'll notice as you enter content that a live preview appears and that the Save button becomes selectable in the top-right. Clicking Save will create the snippet, allowing it to be referenced in templates using the aforementioned {{ snippet "snippet name" }}
block.
Inserting Snippets into Templates
Now that you have a snippet, navigate to the template(s) you want to insert it into. In this case, we'll be working with an email template.
Find the "Insert Snippet" button above the email body editor.
Click this button to view the available snippets and to copy the {{ snippet "snippet name" }}
block for insertion into the template.
You'll notice the "Render HTML?" toggle above. If your snippet contains HTML, we recommend wrapping the insertion handlebars in triple curly braces - {{{ snippet "snippet name" }}}
. Failure to do so will result in the content being displayed as plain text.
Enter or paste the snippet handlebars into the desired location in your template:
Notice the handlebars appear in the live preview. To see them in a rendered state, go to "Preview with data" or "Preview on devices".
Here you see the snippet rendered in Preview with data:
Editing Snippets
Remember, if you make a change in a snippet, the change will propagate to all templates that reference the snippet (including those tied to live campaigns).
Let's say you want to add an additional graphic to your header snippet. To do this, you'd navigate to Templates > Snippets, select the header snippet, insert the image and surrounding code, then save.
To see the changes reflected in a template, open a template that references the snippet, then open "Preview with data" or "Preview on devices". Notice the update in the Preview on devices preview below.
Note: Whenever using Preview on devices, keep in mind that previews do not always reflect the most recent version of the template. Click "Regenerate Previews" to capture a fresh set of previews.
Special Considerations
Email and In-App
If your snippet contains CSS styling, the typical rules apply in terms of the styling that takes precedence (between the snippet and the template). Being mindful of where the snippet falls in the greater template:
- Inline CSS (HTML style attribute) overrides CSS rules in style tag.
- A more specific selector takes precedence over a less specific one.
- Rules that appear later in the code override earlier rules if both have the same specificity.
- A CSS rule with
!important
always takes precedence.
Make sure to close all HTML tags that you open (unless you're intentionally leaving a tag open).
SMS and Push
We recommend that you use only plain text for these message mediums, since HTML will not render like it would for email.
Notes
1) You can insert CSS styles from your snippet, into your templates
2) If you change the name of the snippet it will not be changed in your templates and the link will be broken.
Comments
0 comments
Please sign in to leave a comment.