#14078: Template tag to set context variable to output from tag's rendered 
content
-----------------------------+----------------------------------------------
 Reporter:  mitar            |       Owner:  nobody    
   Status:  new              |   Milestone:            
Component:  Template system  |     Version:  1.2       
 Keywords:                   |       Stage:  Unreviewed
Has_patch:  0                |  
-----------------------------+----------------------------------------------
 I have made a tag which renders its content and puts the result into the
 context variable. I believe it would be useful to include it into built-in
 template tags. The syntax is `{% setcontext as var_name %}...{%
 endsetcontext %}.

 It is most useful when you wan to generate some translated (localized)
 HTML code and pass it to other tags or filters for processing (especially
 multiple times):

 {{{
 {% setcontext as heading %}
 {% url view_page page.get_current_id as page_url %}
 {% blocktrans with page.name|default:_("untitled") as page_name %}
 Edit {{ page_element }} for Page <a href="{{ page_url }}">{{ page_name
 }}</a>
 {% endblocktrans %}
 {% endsetcontext %}
 }}}

 And then you can use `{{ heading|striptags }}` for HTML `title`, `{%
 heading 3 heading %}` for rendering heading (a custom template tag) with
 level 3 and above content.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14078>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to