docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a function that generates MJML email templates for a multi-section newsletter layout.
Create a function buildNewsletterTemplate(data) that accepts configuration data and returns a complete MJML template string. The newsletter should include:
The function must generate valid MJML markup using the standard component library.
{
hero: {
backgroundImage: "https://example.com/hero.jpg",
title: "Monthly Newsletter",
subtitle: "December 2025 Edition"
},
sections: [
{
type: "article",
heading: "Feature Story",
content: "Lorem ipsum dolor sit amet..."
},
{
type: "cta",
text: "Read More",
href: "https://example.com/article"
},
{
type: "image",
src: "https://example.com/image.jpg",
alt: "Feature image"
},
{
type: "divider"
}
],
social: [
{ network: "facebook", href: "https://facebook.com/example" },
{ network: "twitter", href: "https://twitter.com/example" }
],
copyright: "© 2025 Example Corp"
}The function should return a valid MJML string that can be compiled to HTML using mjml2html().
Given a configuration with a hero, 2 article sections, 1 CTA, and a social footer, the function returns valid MJML that includes mj-hero, mj-text, mj-button, and mj-social components @test
Given a configuration with an image section, the function returns MJML with an mj-image component that has proper src and alt attributes @test
Given a configuration with a divider in the sections array, the function returns MJML that includes an mj-divider component @test
The generated MJML uses proper structure with mj-body, mj-section, and mj-column components for layout @test
/**
* Builds an MJML newsletter template from configuration data
* @param {Object} data - Configuration object with hero, navigation, sections, social, and copyright
* @returns {string} Complete MJML template string
*/
function buildNewsletterTemplate(data) {
// Implementation
}
module.exports = { buildNewsletterTemplate };Provides the email markup language and component system for building responsive email templates.
The function should generate MJML markup that uses standard components including:
mj-body, mj-section, mj-columnmj-text, mj-button, mj-image, mj-dividermj-hero, mj-social