liminspace / django-mjml

The simplest way to use MJML in Django templates.
MIT License
263 stars 32 forks source link

How to use with blocks? #118

Closed bramski closed 3 years ago

bramski commented 3 years ago

Not sure if I'm using this wrong or if this is simply unsupported, I'm trying to use the django template extensioning...

<mj-body background-color="#eee">

    {% include './components/mjml_header.mjml' %}

    {% block outerhero %}
    <mj-section css-class="wrapper-title" background-color="#616E8E">
      <mj-column>
        <mj-text>
          <h1>
            {% block hero %}
            {% endblock %}
          </h1>
        </mj-text>
      </mj-column>
    </mj-section>
    {% endblock %}
    {% block content %}
    {% endblock %}

    {% include './components/mjml_contact.mjml' %}

    {% include './components/mjml_footer.mjml' %}

  </mj-body>

When I try and put mjml in an area like outerhero the mjml is just coming through as tags. Suggestions?

bramski commented 3 years ago

Nevermind. I figured this out. Turns out if I override block instead of outhero and that is within an h1 tag then all the tags come out as literals because of the containing h1.