Opened 18 months ago

Closed 17 months ago

Last modified 17 months ago

#21881 closed Bug (fixed)

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

Reported by: nagyv 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 17 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 18 months ago by bmispelon

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 18 months ago 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

comment:3 Changed 18 months ago by bmispelon

  • Component changed from Template system to Documentation
  • Easy pickings set
  • Summary changed from block tags behavior with {% ssi %} is broken to Clarify that `{% ssi ... parsed %}` has the same limitations as `{% include %}`
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 18 months ago by mamun

  • Owner changed from nobody to mamun
  • Status changed from new to assigned

Changed 17 months ago by alextreme

comment:5 Changed 17 months ago by alextreme

  • Has patch set

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

comment:6 Changed 17 months ago by Baptiste Mispelon <bmispelon@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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 Changed 17 months ago by Baptiste Mispelon <bmispelon@…>

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