Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21881 closed Bug (fixed)

Clarify that `{% ssi ... parsed %}` has the same limitations as `{% include %}`

Reported by: Viktor Owned by: mamun
Component: Documentation Version: 1.5
Severity: Normal Keywords: ssi block
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Please, see https://github.com/pulilab/django-ssi-tag-block for a simple test app that demonstrates this bug.

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.

Attachments (1)

django_templates_ssi_rendering_note.patch (727 bytes ) - added by alextreme 11 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Baptiste Mispelon, 11 years ago

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

comment:2 by Viktor, 11 years ago

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

comment:3 by Baptiste Mispelon, 11 years ago

Component: Template systemDocumentation
Easy pickings: set
Summary: block tags behavior with {% ssi %} is brokenClarify that `{% ssi ... parsed %}` has the same limitations as `{% include %}`
Triage Stage: UnreviewedAccepted

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?

comment:4 by mamun, 11 years ago

Owner: changed from nobody to mamun
Status: newassigned

comment:5 by alextreme, 11 years ago

Has patch: set

I've added a small note to the {% ssi %} tag documentation to clarify its behaviour.

comment:6 by Baptiste Mispelon <bmispelon@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

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

comment:7 by Baptiste Mispelon <bmispelon@…>, 11 years ago

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

Note: See TracTickets for help on using tickets.
Back to Top