Carl Meyer skrev 2013-04-18 00:09:
Hi Emil,
On 04/17/2013 04:00 PM, Emil Stenström wrote:
Carl Meyer skrev 2013-04-17 18:37:
Why not instead add a new block to base.html? So you'd change base.html
to have:
{% block outer-content %}
{% block content %}{% endblock content %}
{% endblock outer-content %}
And base_with_warning.html:
{% extends "base.html" %}
{% block outer-content %}
<div class="warning">...</div>
{% block content %}{% endblock content %}
{% endblock outer-content %}
Thanks for your reply! This is the same suggestion Jacob suggested one
minute before you. See my reply to him for my explanations of the
problems with this solution.
I think you may need to re-read my suggestion more carefully.
This is not the same as your Alternative 1, and your objection does not
apply. Templates inheriting from either base.html or
base_with_warning.html can both override the "content" block, and don't
need to know or care about the "outer-content" block.
Ah, I see what you mean now. Sorry for being slow, it's late here. It IS
different from Jacobs suggestion too.
It looks a little bit hacky to double-define the block in base.html.
There's the chance that some child templates to base.html start
inheriting from content, and some from outer-content, since both work.
Also this doesn't work if we want to do the same with base_with_warning,
as we then would have to add another wrapper block around content there.
Despite this problems, I agree that that's a nicer solution than all the
other alternatives.
/Emil
--
You received this message because you are subscribed to the Google Groups "Django
developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.