title: Reusable email layout in MJML
body: <p>I evaluate mjml as a tool for making my days less horrible when I need to do something with transactional emails and there is one feature that I can't find any informations of but I'm just sure there is a way for people to do it right.</p>
  
  <p>Reusable layout.</p>
  
  <p>I used to write emails in pug and it was basic feature there. I know mjml wants to be a framework and not template engine but they do have "mj-include" and layout is kind of reverse include.</p>
  
  <p>Pseudo code explaining what I would like to achieve:</p>
  
  <p>layout.mjml</p>
  
  <pre><code>&lt;mjml&gt;
    &lt;mj-head&gt;...&lt;/mj-head&gt;
    &lt;mj-body&gt;
       ... some header
       &lt;mj-this-is-where-content-comes&gt;&lt;&lt;/mj-this-is-where-content-comes&gt;
       ... some footer
    &lt;/mj-body&gt;
  &lt;/mjml&gt;
  </code></pre>
  
  <p>welcome-user.mjml</p>
  
  <pre><code>&lt;mj-layout src="./layout.mjml"&gt;
    &lt;mj-text&gt;
       Hi user!
    &lt;/mj-text&gt;
  &lt;/mj-layout&gt;
  </code></pre>
  
  <p>Based on my reading I see few ways how people could deal with it:</p>
  
  <ul>
  <li><p>mj-include &lt;= documentation examples stands on that, still requires lots of copy and paste for each template</p></li>
  <li><p>wrapping template with layout in compile process &lt;= I'm loosing the power of mjml tools in this case, I could though set-up watchers that compile and wrap my code in layout for each change</p></li>
  <li><p>custom component &lt;= seems like the best option but aren't reusable layouts such a common case that if it would be a solution then by now I would probably find custom component for it</p></li>
  </ul>