On Fri, Apr 29, 2011 at 4:48 PM, Jonathan Slenders
<[email protected]> wrote:
> Hey, this pattern are nested decorators in templates.
>
> Most people here are probably against having nested template tags with
> the same name. I think it does only make sense when there's somehow a
> distinction between a
> "placeholder" and "content". Because otherwise, templates don't know
> which block in the parent template need to be chosen when several have
> the same name. (You'd say the most inner block, but that's not obvious
> -- I think.)
>
> I once wrote a {% decorate %} template tag for a little similar
> behaviour.
> https://github.com/citylive/django-template-tags/blob/master/src/django_template_tags/templatetags/decorate.py
>
> That would become:
>
> template.html:
> {% decorate (either "a.html" or "b.html") %}
> middle
> {% enddecorate %}
>
>
> b.html:
> {% decorate "a.html" %}
> left {{ decorator.content }} right
> {% enddecorate %}
>
> a.html:
> first {{ decorator.content }} last
>
> Hope that helps.
> I once tried to get this into django trunk, but did not yet got
> accepted.
For me, this:
> {% decorate (either "a.html" or "b.html") %}
is enough of a reason to reject this proposal -- I fundamentally have
no idea what this is trying to say, or why it's trying to say it this
way. Why does a base template need to reference the names of the
templates that descend from it? For me, this is completely bass
ackwards.
I'm also slightly confused as to why your proposal isn't already covered by:
template.html
{% block decorated %}
middle
{% endblock %}
a.html
{% extends template.html %}
{% block decorated %}left {{ block.super }} right{% endblock %}
b.html
{% extends template.html %}
{% block decorated %}first {{ block.super }} last{% endblock %}
Yours,
Russ Magee %-)
--
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en.