Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django templates: include template passing translated variable

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
%}
like image 276
Joseph Victor Zammit Avatar asked Nov 29 '13 15:11

Joseph Victor Zammit


1 Answers

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 %}
like image 85
Emilio Conte Avatar answered Oct 12 '22 10:10

Emilio Conte