MJML - Template Interpolation, Dynamic Data, Context

前端 未结 1 1073
無奈伤痛
無奈伤痛 2021-02-20 15:28

After a lot of searches, I am having difficulties in finding how:

  1. MJML handles dynamic data and template interpolations

I was expecting something l

1条回答
  •  耶瑟儿~
    2021-02-20 15:50

    MJML doesn't handle any templating. If you want templates, use a template engine such as handlebars to render to MJML.

    import { compile } from 'handlebars';
    import { mjml2html } from 'mjml';
    
    const template = compile(`
    
      
        
          
            
              {{message}}
            
          
        
      
    
    `);
    const context = {
        message: 'Hello World'
    };
    const mjml = template(context);
    const html = mjml2html(mjml);
    

    0 讨论(0)
提交回复
热议问题