List Info

Thread: recursive template calls




recursive template calls
user name
2006-02-13 22:44:45
On 2/11/06, Robert Wittams <robertwittams.com> wrote:
>
> Shannon -jj Behrens wrote:
> >>  You don't *need* recursion on templates for
threaded messages like
> >>your example app, that's exactly the point

> >
> >
> > Julio, with all due respect for your programming
prowess, I *like*
> > recursion.  It can often make hard problems easy,
even when generating
> > HTML.
> >
> > Anyway, I figured out how to solve the problem
*using recursion*, and
> > I blogged about it:
> > <http://jjinux.blogspot.com/2006
/02/python-recursion-in-django-templates.html>.
> >  It works, but it's nowhere near as elegant as
simply being able to
> > add a function to the template that I could call
recursively. :-/
> >
> > Best Regards,
> > -jj
> >
>
> This is ridiculous. Something like this seems a lot
easier to me...
>
> templatetags.py:
>
> register = template.Library()
>
> register.inclusion_tag('comment')
> def show_comment(comment):
>     {'comment': comment}
>
>
> comment.html:
>
> {% load comments %}
> {% comment.subject %}
> {% comment.body %}
> {% for child in comments.children %}
>    {%show_comment child %}
> {% endfor %}
>
> page.html:
>
> {% show_comment comment %}
>
>
> The moral of the story : custom template tags aren't
really an optional
> bit of the framework. If you don't learn how to use at
least simple_tag
> and inclusion_tag, you will get annoyed quite often.

I think it's unfortunately that template writers have to
resort to
Python just to package up a bit of HTML into a function, but
that's
just my opinion.

-jj
recursive template calls
user name
2006-02-14 00:09:27
On 2/13/06, Shannon -jj Behrens <gmail.com">jjinuxgmail.com> wrote:

I think it's unfortunately that template writers have to resort to
Python just to package up a bit of HTML into a function, but that's
just my opinion.

 
OTOH Python is a lot cleaner than attempts at "designer-friendly" mini-languages.  (CFScript, ActionScript, ...)

-Jonathan
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )