Actually second solution will work (with django 1.10.5 at least) but with 
`safe` filter added (and it's more convinient to use `trimmed` than create 
oneliner):

{% blocktrans trimmed with '<a href="'|add:url_to_sth|add:'">'|safe as 
link_begin and '</a>' as link_end %}
    Lorem lipsum sit dolor amet enim - {{ link_begin }}Sth{{ link_end }}
{% endblocktrans %}



W dniu poniedziałek, 11 stycznia 2010 10:15:25 UTC+1 użytkownik Michael P. 
Jung napisał:
>
> > I'm having a template, where a link shall be inside a translation-
> > marked text. (...)
>
> I've recently run across a similar problem and solved it using some
> nasty with-tag trickery.
>
> In your case the following code should do the trick:
>
> {% url login as login_url %}
> {% with "<a href=\""|add:login_url|add:"\">" as link_begin %}
> {% with "</a>" as link_end %}
> {% blocktrans %}Please {{ link_begin }}login{{ link_end }} to proceed.
> {% endblocktrans %}
> {% endwith %}
> {% endwith %}
>
>
> {% blocktrans %} also has a builtin "with" support, but for some reason
> it does not support escaping special characters.
>
> So the following doesn't work:
>
> {% blocktrans with "<a href=\""|add:login_url|add:"\">" as link_begin
> and "</a>" as link_end %}Please {{ link_begin }}login{{ link_end }} to
> proceeed.{% endblocktrans %}
>
>
> --mp
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68cf1856-48ef-4637-b64b-5e3af9d853c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to