funkybob / django-sniplates

Template snippet libraries for Django
MIT License
57 stars 18 forks source link

Nested widget and {% trans %} template tag. #44

Closed sergei-maertens closed 8 years ago

sergei-maertens commented 8 years ago

Template:

{% extends "mail/base.html" %}
{% load i18n reservation_tags sniplates %}

{% block content %}

    {% load_widgets mail='sniplates/mail.html' %}

    {% nested_widget 'mail:p' %}
        {% trans "You can find the tickets and all visit information per group here. These links
are shareable with the companion of each group:" %}
    {% endnested %}

{% endblock %}

sniplates/mail.html:

Mail sections - to be used as nested_widgets

{% block introduction %}
<!-- introduction -->
<br><br>
<h3 style="color: {{ link_color }};font-family: &quot;Arial&quot;, sans-serif;font-weight: normal;padding: 0;margin: 0;text-align: left;line-height: 1.3;word-break: normal;font-size: 20px;">{{ content }}</h3>
{% endblock introduction %}

Generic content
{% block p %}
<!-- content -->
<p style="margin: 0;margin-bottom: 10px;color: {{ color }};font-family: &quot;Arial&quot;, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 1.3;font-size: 17px;">{{ content }}</p>
{% endblock p %}

Expected output:

<!-- content -->
<p style="margin: 0;margin-bottom: 10px;color: #000;font-family: &quot;Arial&quot;, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 1.3;font-size: 17px;">
       You can find the tickets and all visit information per group here. These links
are shareable with the companion of each group:
    </p>

Actual output:

<!-- content -->
<p style="margin: 0;margin-bottom: 10px;color: #000;font-family: &quot;Arial&quot;, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 1.3;font-size: 17px;">
        {% trans "You can find the tickets and all visit information per group here. These links
are shareable with the companion of each group:" %}
</p>
funkybob commented 8 years ago

Is it only trans tags that don't work?

sergei-maertens commented 8 years ago

So far it is, I am now working around it by using blocktrans instead. Curious case.

funkybob commented 8 years ago

Could you please submit a PR with a failing test?

sergei-maertens commented 8 years ago

Ofcourse, have to get it done outside of the work hours though.

sergei-maertens commented 8 years ago

Hrm, something weird must be going on, can't seem to isolate a failing test. Will investigate further tomorrow.

sergei-maertens commented 8 years ago

Come to think of it, there may have been a newline in the {% trans %} content that I missed, just verified that it works correctly.