Re: Random string template tag

2007-07-05 Thread SmileyChris
Or you could do {{ "class1,class2,class3,class4"|split:","|random }} (you'd need to make the |split filter too, Django only comes with | join) On Jul 4, 3:21 pm, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > If you want to hardcode the availability of the 'classes' variable in > > every context (s

Re: Random string template tag

2007-07-03 Thread Bryan Veloso
> If you want to hardcode the availability of the 'classes' variable in > every context (so you don't have to remember to define it every time), > you could write a context processor. See > django.core.context_processors for examples. That's probably what I'll need since it'll always have to be t

Re: Random string template tag

2007-07-03 Thread Russell Keith-Magee
On 7/4/07, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > > {{ classes|random }} > > Can you serve Context to the base template? > I thought of that earlier, but I couldn't think of how to give it > Context. What do you mean? You pass a context to the template renderer; if the template you render re

Re: Random string template tag

2007-07-03 Thread Bryan Veloso
> One option is to use the 'random' filter; your context would need to > define the list of possible strings: > > Context({ >'classes': ['class1','class2','class3','class4'] > > }) > > but then your template could use: > > {{ classes|random }} Can you serve Context to the base template? I tho

Re: Random string template tag

2007-07-03 Thread Russell Keith-Magee
On 7/4/07, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > I don't know if this exists or not, but I'd like to insert a tag (much > like cycle) that allows the random selection of a string. I'm trying > to randomly assign a class to a to simulate "random image > rotator" type functionality. Something

Re: Random string template tag

2007-07-03 Thread Tim Chase
> I don't know if this exists or not, but I'd like to insert a tag (much > like cycle) that allows the random selection of a string. I'm trying > to randomly assign a class to a to simulate "random image > rotator" type functionality. Something like... > > Sounds like you want to make a custo

Random string template tag

2007-07-03 Thread Bryan Veloso
I don't know if this exists or not, but I'd like to insert a tag (much like cycle) that allows the random selection of a string. I'm trying to randomly assign a class to a to simulate "random image rotator" type functionality. Something like... Any ideas? --~--~-~--~~