我有一个国际化的Django 1.3网站,并希望这样做:在包括模板标签Django的变量替换
{% include "snippets/button.html" with button_text=_("Logout {{ user.username }} now") %}
而且snippets/button.html
看起来是这样的:
<button
type="{{ button_type|default:_('submit') %}"
class="all_my special classes"
{% if button_title %} title="{{ button_title }}"{% endif %}>
<span class=ui-button-text>{{ button_text|default:_("Submit") }}</span>
</button>
的唯一途径,我可以看到这样做是这样的:
{% include "snippets/button.html" with button_text="Logout "|add:user.username|add:" now" %}
但这是不可接受的,因为字符串将需求转化为包括发生变量替换的地方。我已经看到Interpolate Django template include variable但这不包括这种用法。