On 2/17/06, Maniac <[EMAIL PROTECTED]> wrote:
>
> limodou wrote:
>
> >{% calendar year month %}
> >
> >
> It's perfectly possible (strange I can't find it in the docs now but I
> knew it from there).
>
> In your tag function you should wrap all the parameters in a special
> parser object which then will be evaluated with a context:
>
> def do_calendar(parser, token):
>   bits = token.contents.split()
>   return CalendarNode(parser.compile_filter(bits[1]),
> parser.compile_filter(bits[2]))
>
> This parser.compile_filter creates such object from the parameters. It
> can accept variables with filters as well as constant strings. You can't
> actually evaluate these bits right now because parsing happens before
> real values passed into template. It's your class' render method where
> you can resolve these parsed bits with given context:
>
> class CalendarNode(template.Node):
>   def __init__(self, year_expr, month_expr):
>     self.yesr_expr, self.month_expr = year_expr, month_expr
>
>   def render(self, context):
>     year = self.year_expr.resolve(context)
>     month = self.month_expr.resolve(context)
>

It sounds very excellent. I'll try it. Thank you very much.

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to