Django templates: include template passing translated variable

django, django-templates

Solution

I found the solution in this post:

Here is the given example:

{% trans "Load more promotions" as promotions %}
{% include "a_dir/stuff.html" with text=promotions %}

Problem

I need to pass the following into an included template via the Django include tag: ``` {% include 'btn.html' with btn_text='Hi '|add:first_name|add:' - Verify Email Now' btn_url=verify_url %} ``` Therefore I can dissect the entire question in two parts: A. Is it possible to have `first_name` added into the string in another, more elegant, manner at template level? B. I need to have the string translated at template level - is it possible? I.e. what I intend to do (but is not syntactically correct) is the below: ``` {% include 'btn.html' with btn_text= {% blocktrans first_name as first_name %} Hi {{first_name}} - Verify Email Now {% endblocktrans %} btn_url=verify_url %} ```

Original source

Related problems