This is my welcome container:
<tr>
<td align="center">
<!-- Start internal container -->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="30" style="line-height:30px; font-size:30px;"> </td>
</tr>
<tr>
<td align="left" style="font-family: 'Lato', sans-serif; font-size:20px; line-height:26px;">
<p style="font-family: 'Lato', sans-serif; margin: 0; padding: 15px 60px 15px 60px; font-weight: bold; color: #333333;">
{{ title }}
</p>
<p style="font-family: 'Lato', sans-serif; font-size:16px; margin: 0; padding: 0px 60px 0px 60px; color: #333333;">
{{ subtitle }}
</p>
</td>
</tr>
</table>
<!-- End internal container -->
</td>
I tried this:
{% "Hi {{first_name}}" as titleStr%}
{% with title=titleStr subtitle="Please confirm your email address by clicking this button." %}
{% include "emails/_parts/welcome_container.html" %}
{% endwith %}
But I get this issue:
Invalid block tag on line 29: '"Hi', expected 'endblock'. Did you forget to register or load this tag?
What am I doing wrong? Line 29 is the one with title=titleStr
you write {% "Hi
, and django template know this is start of block tag. If you want show text only, change it to "Hi {{first_name}}"
if you want pass variable with include, try this:
{% include "emails/_parts/welcome_container.html" with title={{first_name}} %}
document for include https://docs.djangoproject.com/en/2.1/ref/templates/builtins/#include
You have added {% "Hi" %}
in template where django considers 'Hi' as template tag but it does not exists in django and that's why its throwing an error. You probably want add Hello in front of title variable and pass it to the another template. You can do this via add
template tag.
{% with "Hello "|add:first_name as titleStr %}
{% include 'emails/_parts/welcome_container.html' with title=titleStr subtitle="Please confirm your email address by clicking this button." %}
{% endwith %}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.