On 25 August 2010 08:59, Yo-Yo Ma <[email protected]> wrote:
> This is of course very painful, but the thing that makes it worse is
> that I have to override each block 2 times with the exact same code
> (foo_section/list.html and foo_section/form.html have the same tabs
> and therefore have 15-20 lines of the exact same HTML in each).
You could use an {% include %} to avoid repeating the code.  This has
a downside - if you want to add a new block to the base template, you
have to go through all the sub-templates and insert the block with the
include.

> This is true with each level of "form.html" and "list.html". If I could
> inherit from two or more templates, and have the later override any
> blocks from the former, I could do this:
>
> baseform.html
> baselist.html
>    foo_section/tabs.htmlthe
>    foo_section/form.html
>    foo_section/list.html
>    foo_section/spam_sub_section/tabs.html
>    foo_section/spam_sub_section/form.html
>    foo_section/spam_sub_section/list.html
>
> For example, Inside of  foo_section/form.html and foo_section/
> list.html it would have only:
>
> {% extends "form.html" "foo_section/tabs.html" %}
>
> I might be designing this all wrong, but it seems that working with
> tabs is very difficult to do without having hundreds of templates. If
> my feature request is lamo, any help or suggestions are much
> appreciated instead.
If I understand correctly this

    template_C::

    {% extends "A" "B" %}
    {% block X %} This template's code {% endblock %}

would be the same as:

    template_C::

    {% extends "A_withB" %}
    {% block X %} This template's code {% endblock %}

    A_withB::

    {% extends "A" %}
    {% include "B" %}

If yes, then I would support this, because it makes templates more
maintainable. You avoid both the include and "A_withB" type templates.

-- 
Łukasz Rekucki

-- 
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.

Reply via email to