RebelMouse Talk to Us
Using Mustache Syntax to Customize Mailchimp Templates

Using Mustache Syntax to Customize Mailchimp Templates

RebelMouse has many ways that we can help to simplify your newsletter campaign workflow. Our integration with Mailchimp allows you to automate your daily or weekly newsletter (using an algorithm to select the top-performing posts of either period) or to use our Entry Editor to create a post, which can then be sent to Mailchimp and distributed to your appropriate lists. You are also able to simply select the correct template for any post you send as a newsletter (or your automated newsletters).


Here we will describe how to use the Mustache template syntax with data to render posts in your newsletters. This is a method that we created to make it easy to augment your newsletters by using Mustache templates. You can learn more about the Mustache template here: https://mustache.github.io/mustache.5.html

To tell an HTML block to render as a Mustache template, we need to create an HTML tag with the "mc:edit" attribute, and have it contain the value "_mustache" as a postfix. For example:

<div mc:edit="posts_list_mustache"></div>

Then, during rendering of the newsletter, the Mustache syntax will be replaced with variables from our posts.

The minimal code needed would be, for example, this code snippet:

<div mc:edit="posts_list_mustache">
 {{#posts_list}}
  {{#image600x}}
  <a href="{{ post_url }}"><img src="{{image600x}}"></a>
  {{/image600x}}
  {{#header}}
   <a href="{{ post_url }}" target="_blank">{{ header }}</a>
  {{/header}}
 {{/posts_list}}
</div>

List of Variables

For the "posts_list" List:

Name

Description

header

Header/Headline of a post

subheader

Subheader/Subheadline of a post

post_url

Post URL

image600x

Lead image 600x

image300x

Lead image 300x

image980x

Lead image 980x

image

Image (this displays an image and works in Gmail correctly)

before_listicle

Body text before listicle/particle

after_listicle

Body text after listicle/particle

authors_names

Author names list

author_name0, author_name1, author_name2, author_name{}

Author names

author_avatars

Author avatars list

author_avatar0, author_avatar1, author_avatar2, author_avatar{}

Author avatars

created_date

Created date

keep_reading_enabled

Is keep reading enabled for the post

tags

Tags list

listicle_items_list

A list of listicles/particles

related_posts_list

A list of related posts

For the "listicle_items_list" List:

Name

Description

is_image

Check if the image is set for a given listicle/particle

image600x

Listicle/Particle 600x px image

image

image (this displays an image and works in Gmail correctly)

media_html

Sometimes instead of the lead image, media HTML might be defined

headline

Listicle/Particle headline

body

Listicle/Particle body

item_permalink

Particle URL

has_brief

True if the post has brief parameter filled (used to determine Keep Reading)

brief

Brief parameter (used to show the first part of Keep Reading)

For the "listicle_items_by_groups" List:

(In case you are dealing with multicolumn listicles.)

Name

Description

is_multicolumn

Marks if a given particle is multicolumn

is_layout_two_columns

Is this a two-column layout

is_layout_three_columns

Is this a three-column layout

parallax

Is this a parallax layout

ecommerce

Is this an e-commerce layout

item0

First item of a particle

item1

Second item of a particle

item{}

Where {} is a number, it will render information about a given item. So in case we are dealing with a three-column layout, we will have item0, item1 and item2. For a two-layout column, it's item0 and item1. And for single-column layout, only item0 will be available.

has_sponsored_slug

A Boolean that determines if slug of particle is starting with sponsored content or a sponsored response. Used to determine if the post is sponsored.

has_brief

True if the post has a brief parameter filled (used to determine Keep Reading)

brief

Brief parameter (used to show the first part of Keep Reading)

For the Item object for the "listicle_items_by_groups" List:

Name

Description

basename

Item base name

images

Please refer to the "image choices" section

is_first

Is it the first particle

is_last

Is it the last particle

is_image

Does the particle contain an image

headline

Particle headline

media_html

Sometimes instead of the lead image, media HTML might be defined

href

A URL to a given particle

id

ID of a particle

index

Index of a particle

item_permalink

Link to a given particle

body

Particle body (not parsed)

description

Particle description (parsed)

Image Choices:

Name

Description

is_image

Checks if an image is set for a given listicle/particle

image600x

Listicle/Particle 600x px image

image

Image (this displays an image and works in Gmail correctly)

imageorigin

Same as image

image210x

Image 210x

image300x

Image 300x

image600x

Image 600x

image980x

Image 980x

image35x35

Image 35x35

image300x300

Image 300x300

image600x200

Image 600x200

image600x300

Image 600x300

image600x400

Image 600x400

image600x600

Image 600x600

image750x1000

Image 750x1000

image700x1245

Image 700x1245

image1000x750

Image 1000x750

image1200x400

Image 1200x400

image1200x600

Image 1200x600

image1200x800

Image 1200x800

image1245x700

Image 1245x700

image1500x2000

Image 1500x2000

image2000x1500

Image 2000x1500

Here is an example of a simple HTML template with Mustache syntax used: https://gist.github.com/kkszysiu/0dca4715dd55b66e4c7e23478411727c

Creating a Template in Mailchimp

To create a template in Mailchimp, we need to log in to the Mailchimp dashboard, then go to the Templates view and create a new template:

Then select the "Paste in code" option in the next step:

Now you can copy-paste the sample template from the GitHub link above.

Once that's been entered, you simply click Save and Exit in the bottom-left corner of the screen. Then you'll be prompted for a name for the template. Enter a familiar name for your template that helps keep you organized and you're through this part! You can continue to edit the template to make it fully your own, too.

Testing the Template

To test your template, the easiest way would be to create a new "Audience" or "List" in your Mailchimp dashboard, and then add test emails to your newly created audience.

From our Entry Editor, go to the Send a Newsletter tab and select your newly created audience and test template:

After publishing a post, you should receive a test email that uses the test template. Note that if you have any errors in the code in the template, Mailchimp may not receive the newsletter. If you notice that the draft isn't appearing in your Campaigns tab in Mailchimp when you send to Mailchimp, you'll want to check your code to be sure that there are no errors.

You can repeat this flow by changing something in your template, saving it, and then editing this post in Entry Editor and checking the changes in the emails you will receive.

If you have any questions, please contact your account manager or support@rebelmouse.com.

Why RebelMouse Is the Best Content Marketing Platform

RebelMouse is a unique platform and company. The company was founded on the vision that media companies would need an always-modern solution to thrive in the new connected internet, and that brands would have to behave like new media companies and use the same platforms.

Keep reading... Show less

Why Premium Creative Agencies and CTOs Choose to Develop on RebelMouse vs. WordPress and Drupal

The Intersection of Design and Development: Where Your Clients Thrive

We started RebelMouse seven years ago knowing that there was a fundamental design flaw in the world of traditional CMSs: Every instance, on every platform, had to be updated independently. It's similar to an era when users had to manage their own Microsoft Exchange Server for email. The costs of managing, maintaining, and iterating on a CMS to keep it awesome and world class is typically a $10 million-a-year endeavor. But even then, these cost-prohibitive CMSs are still behind the times.

Keep reading... Show less

Native Multivariate Testing at Scale With RebelMouse

What Differentiates Our Approach

There are many popular tools that allow you to perform experiments and A/B tests on your users — primarily Google Chrome Experiments and Optimizely. But all of these solutions are JavaScript additions to your web page that sidestep the problem of old, outdated, and clumsy CMSs. These solutions work by calling on a third-party JavaScript library that rewrites a page after it's rendered. This approach adds extra page weight and creates strange user experiences due to having to wait for everything to load and be rewritten on the fly.

At RebelMouse, we've solved this in a very elegant way. At the core level of our platform, we can natively render different layouts and track the exact differences in performance when comparing a test to your other layouts.

Keep reading... Show less

Modern E-Commerce: Blur the Line Between Content and Design

Create Modular + Reusable Design Patterns on RebelMouse

Content saturation is an industry-wide problem, and the e-commerce space is no exception given that it's filled with big brands, small Etsy stores, and everyone in between all fighting for similar audiences. The best way to fight this symptom is to understand your audience and provide them with what they want.

Keep reading... Show less

Instagram-style E-commerce Features on RebelMouse

Revolutionizing e-commerce on RebelMouse

Whether you're a brand with a blog or a media company with a site, driving purchasing behavior and building an audience that uses your content to find things they love to buy is vital. We're very proud to have built out the same functionality that everyone is now used to on Instagram, with layovers on images that lead to products with attribution.

Keep reading... Show less

Building Premium Communities and User Journeys on RebelMouse

RebelMouse is much more than just a replacement for a traditional CMS. Our platform is a tremendous community-building experience. Today's social ecosystem has given us a seemingly limitless number of premium creators who understand how to create gorgeous and relevant content that drives the growth of their own audiences. These creators and influencers are either experts in certain topics, or heavily engaged in targeted content that drives their interests. They're not only consuming the content they're passionate about, but they're contributing to the conversation, too. The new role of the editor is not just to cover the most important topics and people around their expertise, but also to invite those preferred influencers into their community and get them to participate in creating premium content.

Keep reading... Show less

Dynamic Voting: Grow Traffic and Engagement Organically

Help your audience find its voice.

Creating quality content is no longer on marketers alone. We live in a universe of creators who are willing to not only consume content that resonates, but play a role in the creation, promotion, and conversations surrounding it.

Since the start of RebelMouse, we've been on a journey to create dynamic media that is easier for content creators to curate and amplify on social. It's why we've built an online engagement platform centered around the power of communities that thrive naturally in the digital ecosystem.

Keep reading... Show less

How to Monetize Your Website in Today’s Publishing Environment

In order to define distributive publishing, we have to ask the following question: If you have quality content, but nobody sees it, does it even exist? The answer is no, because your content needs to be supported in a way that lets it move seamlessly across all channels, especially site, search, and social. But let's take this question a step further: If you can't monetize your content to generate the support it needs, how do you create quality content in the first place?

Keep reading... Show less

RebelMouse Q3 2021 Platform Performance Updates

For many publishers and brands, Q3 2021 was about recovering web traffic lost to Google's page experience signals update that was rolled out over the summer. For us, the quarter was about continuing our success of delivering excellent Core Web Vitals metrics across our site network with platform performance updates both big and small.

As a globally distributed team, it's important for us to remain transparent about how we're able to power some of the best-performing sites on the open web. And while we're already looking forward to closing out the year stronger than ever before, here's a detailed look back at our accomplishments in Q3 2021.

We invested 1,946 hours into our platform in Q3 2021 alone, and all of the sites on our platform benefited from the work in various ways. Here are the key areas that we focused on:

  • 184 hours were spent on delivering new features
  • 1,010 hours were spent on improving existing features
  • 752 hours were spent on performance and infrastructure updates
Keep reading... Show less

RebelMouse Clients See Performance Improvement After AMP Optimization

Performance is a major pillar of our platform, which means we are always making changes — both big and small — to improve page speed. Our focus on fast websites isn't platform specific, either. We want to make sure that users have a top-notch experience however they view your content, and this includes our integration with Google's AMP format.

Our team of traffic-obsessed developers recently implemented some performance optimizations to enhance our platform's integration with AMP, and that has improved the average response time for our clients. This means that users are able to access your AMP pages more quickly, which, in turn, improves your site's traffic from Google.

Here's a breakdown of the changes we've made:

Keep reading... Show less

Keep Search a Priority With SEO-Friendly Image Filenames

There are a lot of factors that go into a successful search engine optimization (SEO) strategy, including performance, structured data, and, of course, choosing the right keyword(s). Our proprietary search technology helps content creators prep every article for success on search. This all-encompassing approach includes the use of SEO-friendly image filenames.

On RebelMouse, if you assign an alt tag to an image in Entry Editor, that alt tag will also become the image's file name. Briefly, alt tags describe images for search engines, and also allow people using screen readers to know what the image is without actually being able to see it. Adding your desired search phase to every alt text field, and in turn every image file name, will reinforce its relevance to Google's crawler, bringing you one step closer to the top of search returns.

Keep reading... Show less
Subscribe to Our Newsletter