#6378: Capture arbitrary output as a template variable
---------------------------------------------+------------------------------
          Reporter:  kcarnold                |         Owner:  nobody
            Status:  new                     |     Milestone:        
         Component:  Template system         |       Version:  SVN   
        Resolution:                          |      Keywords:        
             Stage:  Design decision needed  |     Has_patch:  0     
        Needs_docs:  0                       |   Needs_tests:  0     
Needs_better_patch:  0                       |  
---------------------------------------------+------------------------------
Comment (by ericholscher):

 @Malcolm: I couldn't find the discussion from django-dev, "with" is
 stripped out by google's search. Anyway, here is an idea I've had about
 this functionality.

 How about implementing this as an optional "into" (colored appropriately)
 where you could have a statement along the lines of

 {{{
 {% with person.get_absolute_url as main_url into content %}
 check out my page: {{ main_url }}
 {% endwith %}
  }}}

 This would then instead of outputting the included block into the
 template, stuff it into the content variable.

 However, this doesn't cover the situation where you don't want to put a
 new variable into the context, but you simply want to put that output into
 a variable. Something along the lines of {{{ {% with [None|magic_word]
 into content %} }}} was the best I could come up with.

 I think that capturing the output of a block is a different operation than
 including a variable into the inner block's context. Maybe a better
 solution would be to have a {{{ {% withblock as content %} }}} tag that is
 a counterpart to the "with" tag.

 It feels like this functionality shouldn't go in two places, so maybe
 "withblock" would also have the ability to set the context variables
 inside. Seems bad to have the functionality in two places either way. The
 best situation would probably be a sane way to define the capture syntax
 on the "with" tag, without settings the context variable.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/6378#comment:4>
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