Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using tags with {{ block.super }} #117

Open
rwilson opened this issue Mar 23, 2016 · 3 comments
Open

Using tags with {{ block.super }} #117

rwilson opened this issue Mar 23, 2016 · 3 comments
Labels

Comments

@rwilson
Copy link
Contributor

rwilson commented Mar 23, 2016

It seems {% style "some/style.css" %} tags don't render within {{ block.super }} calls, while explicit <link ... /> tags render as expected within a {{ block.super }} call.

For example, here's a cascading a->b->c hierarchy, each which includes 2 stylesheets in the block head: one named "*-style.css" rendered with a {% style ... %} tag, and the other "*-link.css" rendered with an explicit <link ... /> tag.

The final child, c, is the only one which renders a link from the "*-style.css" tag. The parents do not, even though each child calls {{ block.super }}. However, the explicit <link ... /> tags are rendered by the {{ block.super }} calls.

a.html

<!DOCTYPE html>
<html lang="en">
  <head>
    {% block head %}
    {% style "a-style.css" %}
    <link href="a-link.css" rel="stylesheet" />
    {% endblock %}
  </head>
  <body></body>
</html>

b.html

{% extends "a.html" %}

{% block head %}
{{ block.super }}
{% style "b-style.css" %}
<link href="b-link.css" rel="stylesheet" />
{% endblock %}

c.html

{% extends "b.html" %}

{% block head %}
{{ block.super }}
{% style "c-style.css" %}
<link href="c-link.css" rel="stylesheet" />
{% endblock %}

I just ran this in a repl for a quick test, here's the output:

user=> (println (selmer.parser/render-file "c.html" {}))
<!DOCTYPE html>
<html lang="en">
  <head>
    <link href="a-link.css" rel="stylesheet" />
    <link href="b-link.css" rel="stylesheet" />
    <link href="c-style.css" rel="stylesheet" type="text/css" />
    <link href="c-link.css" rel="stylesheet" />
  </head>
  <body></body>
</html>

Is it intended that style tags do not render within {{ block.super }}? If so, is it an intentional behavior that applies to other tags as well? I've only tested with style so far.

I also dumped a minimal repro here.

@rwilson
Copy link
Contributor Author

rwilson commented Mar 23, 2016

After testing a few other cases, this applies to the style and include tags as well. Are tags intentionally unsupported via {{ block.super }}?

@rwilson rwilson changed the title Using style tag with {{ block.super }} Using tags with {{ block.super }} Mar 23, 2016
@yogthos
Copy link
Owner

yogthos commented Mar 24, 2016

Hi,

It's been a little while, I'll have to take a look at the specifics, but I suspect it's due to the fact that tags get run at compile time, while block.super operates at runtime on the compiled template.

@TwiceII
Copy link

TwiceII commented Jul 20, 2016

Hi,

I confirm, it seems like tags in parent's block are ignored if called with {{block.super}}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants