Re: Feature request - set variables in template

2010-08-27 Thread Alex Robbins
I think the thread Brian is thinking of is this one: http://groups.google.com/group/django-developers/browse_thread/thread/31f0d2302c07a75b/1c41d02147316f3e?lnk=gst=New+context#1c41d02147316f3e If everyone can agree on the tag's syntax, I'd definitely work on writing the patch. Alex On Aug 26,

Re: Feature request - set variables in template

2010-08-26 Thread Russell Keith-Magee
On Fri, Aug 27, 2010 at 9:27 AM, Brian O'Connor wrote: > I think this got brought up in the forums a month or so ago, but I'd like to > see a 'shortcut' for setting variables much like we have a shortcut for > registering inclusion templatetags.  Having to write a full

Re: Feature request - set variables in template

2010-08-26 Thread Mike Axiak
Perhaps you should ask django-users (or the IRC channel, #django, or stackoverflow, ...), how they would approach solving your particular problem. I know that for me it took a few months before I realized how perfect writing custom template tags (or template inclusion tags) are for many blocks of

Re: Feature request - set variables in template

2010-08-26 Thread Russell Keith-Magee
On Fri, Aug 27, 2010 at 9:22 AM, Yo-Yo Ma wrote: > I see what you're saying Russell. I myself am reluctant to use the > template tag I created in some ways. Although I cannot seem to find a > DRY way of doing what I'm doing Factor the logic out of your template so that

Re: Feature request - set variables in template

2010-08-26 Thread Brian O'Connor
I think this got brought up in the forums a month or so ago, but I'd like to see a 'shortcut' for setting variables much like we have a shortcut for registering inclusion templatetags. Having to write a full fledged templatetag to set a variable is a bit much. Brian On Thu, Aug 26, 2010 at 9:22

Re: Feature request - set variables in template

2010-08-26 Thread Yo-Yo Ma
I see what you're saying Russell. I myself am reluctant to use the template tag I created in some ways. Although I cannot seem to find a DRY way of doing what I'm doing, the idea of breaking the dogma does bother me a bit. I thought that if I could get confirmation from the crowds, it would make

Re: Feature request - set variables in template

2010-08-26 Thread Russell Keith-Magee
On Fri, Aug 27, 2010 at 8:06 AM, Yo-Yo Ma wrote: > I'm sure this will be met with criticism, but there is a reason why > just about all template languages allow the setting of variables. Yes. It's because most template languages are trying to be a Turing complete

Re: Feature request - set variables in template

2010-08-26 Thread David P. Novakovic
My 2c: The ability for a template editor (ie a frontend developer) to set variables in the global namespace opens up the potential for a designer to clobber variables delivered to the template from the view. The example you've provided is something that really falls to the responsibility of the

Re: Feature request - set variables in template

2010-08-26 Thread Yo-Yo Ma
You absolutely cannot. The "with" statement puts the variable in the scope of the "with" statement only, not to mention that would not be very explicit at all. On Aug 26, 6:14 pm, "David P. Novakovic" wrote: > You can basically do this with the "with" >

Re: Feature request - set variables in template

2010-08-26 Thread David P. Novakovic
You can basically do this with the "with" statement: http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#with On Fri, Aug 27, 2010 at 10:06 AM, Yo-Yo Ma wrote: > I'm sure this will be met with criticism, but there is a reason why > just about all

Feature request - set variables in template

2010-08-26 Thread Yo-Yo Ma
I'm sure this will be met with criticism, but there is a reason why just about all template languages allow the setting of variables. It allows you to do things like: {% for thing in things %} {{ thing }} {% if thing.is_the_one %} {% set_var the_one thing%} {% endif %} {%