What would you expect to be rendered when the `page.html` file gets
rendered with the following templates?
== page.html ==
{{{
{% extends "base.html" %}
{% block content %}
Everything fine. The content block was overwritten!
{% endblock %}
}}}
== base.html ==
{{{
{# included_template == ssi.html #}
{% ssi included_template parsed %}
}}}
== ssi.html ==
{{{
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{% block content %}
This is the original content block. You should never see me.
{% endblock %}
</body>
</html>
}}}
My expectation would be to see the text "Everything fine. The content
block was overwritten!". But this did not happen.
--
Ticket URL: <https://code.djangoproject.com/ticket/21881>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi,
I don't think that's a bug but rather a limitation of the current system.
It's documented as a note for the `{% include %}` tag [1]:
> The include tag should be considered as an implementation of “render
this subtemplate and include the HTML”, not as “parse this subtemplate and
include its contents as if it were part of the parent”. This means that
there is no shared state between included templates – each include is a
completely independent rendering process.
Maybe that should be made clearer in the paragraph for `{% ssi %}` too.
What do you think?
[1] https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#include
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:1>
Comment (by nagyv):
Reading the docs for the `{% ssi %}` tag tells just the opposite [1]:
> If the optional “parsed” parameter is given, the contents of the
included file are evaluated as template code, within the current context
This is the reason why I was using `ssi` instead of `include`.
[1] https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#std
:templatetag-ssi
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:2>
* component: Template system => Documentation
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
That sentence is not completely clear, I'll admit.
The fact is that `{% ssi %}` has the same limitations as `{% include %}`:
even when you use the `parsed` option, included templates are rendered
separately, so you can't for example alter the context or define blocks.
This is what the note in `{% include %}` tries to convey.
I'm going to mark this ticket as `accepted` (and change its description)
but as I see, it's a documentation issue.
We should make it more clear that the `parsed` option has the same
limitation as `{% include %}`.
What do you think?
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:3>
* status: new => assigned
* owner: nobody => mamun
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:4>
* has_patch: 0 => 1
Comment:
I've added a small note to the {% ssi %} tag documentation to clarify its
behaviour.
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"072fb923e1b2e39e85a4ed4569ee7cd94f26a0bb"]:
{{{
#!CommitTicketReference repository=""
revision="072fb923e1b2e39e85a4ed4569ee7cd94f26a0bb"
Fixed #21881 -- Clarify behavior of {% ssi %} template tag.
When using the `parsed` option, {% ssi %} has the same limitation
as {% include %}, namely that the rendering of the included
template is done separately.
Thanks to trac user nagyv for the report and to alextreme for
the patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:6>
Comment (by Baptiste Mispelon <bmispelon@…>):
In [changeset:"a36513c2b41f50856144b8b66d5afc71e264b3cc"]:
{{{
#!CommitTicketReference repository=""
revision="a36513c2b41f50856144b8b66d5afc71e264b3cc"
[1.6.x] Fixed #21881 -- Clarify behavior of {% ssi %} template tag.
When using the `parsed` option, {% ssi %} has the same limitation
as {% include %}, namely that the rendering of the included
template is done separately.
Thanks to trac user nagyv for the report and to alextreme for
the patch.
Backport of 072fb923e1b2e39e85a4ed4569ee7cd94f26a0bb from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21881#comment:7>