Hi all,

This seems like a weirdness in template inheritance...

base.html

{% block title %} ... {% endblock %}
{% block content %}... {% endblock %}


index.html
{% extends "base.html" %}
{% block content %}
  {% block title %}
      <p>some text</p>
  {% endblock %}
{% endblock %}


The paragraph is shown twice in the output. Once, because the block
'title' is copied into the 'title' of the parent during the
inheritance, and once because the block 'content' is copied.

I guess this is a flaw in the inheritance algorithm, only the most
outer blocks should be used during the resolving of inheritance.

Because: if we would extend index.html, and override the block
"title", the current template engine will replace the title-block from
base.html, instead of the nested title-block of index.html which is
completely counter-intuitive.

Is this behaviour documented or on purpuse? We should have a clear
definition of how inheritance should work, especially now the Jinja-
guy is working on a compatible template engine. (And also the template
preprocessor does resolve inheritance at compile time.)

It is otherwise possible that people will start using this flaw as a
kind of macro-feature, to intentionally duplicate content.

Jonathan


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