Open marc-medley opened 5 years ago
I'm running into this as well. @kylef @ilyapuchka @djbe Is this expected behavior?
Same problem here, but this issue seems dead. Is this project still alive?
Is this expected behaviour?
I don't think this is expected.
As far as I can tell from the test suite, this would appear to be working: https://github.com/stencilproject/Stencil/blob/22440c5/Tests/StencilTests/InheritanceSpec.swift#L21-L25 which expects Super_Header Child_Header Child_Child_Header\nChild_Body
by rendering child-child.html
which extends child.html
which extends base.html
:
https://github.com/stencilproject/Stencil/blob/22440c5/Tests/StencilTests/fixtures/base.html https://github.com/stencilproject/Stencil/blob/22440c5/Tests/StencilTests/fixtures/child.html https://github.com/stencilproject/Stencil/blob/22440c5/Tests/StencilTests/fixtures/child-child.html
@kevinrenskers If you compare what you have to this test, is there anything in particular that stands out as a difference use-case?
base.html:
<html>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
articles.html:
{% extends "base.html" %}
{% block title %}Articles{% endblock %}
{% block content %}
<h1>Articles</h1>
{% for page in pages %}
<a href="{{ page | url }}">{{ page.title }}</a><br/>
{{ page.summar }}
{% endfor %}
{% endblock %}
year.html:
{% extends "articles.html" %}
{% block title %}Articles in {{ year }}{% endblock %}
When I render the year.html template I would expect that the title would be "Articles in 2021" for example, but it's always just "Articles".
@kylef The outer contructs in base.html
of both my and @kevinrenskers examples are not Stencil {% … %}
patterns. The failing examples have HTML tags <!DOCTYPE html><html lang="en"><head>
and <html><head>
at the outermost starting point.
There may be other differentiating aspects. The above is just the first difference I
noticed in the base.html
files.
It seems to me that the big difference is that our examples don't use super
within a block. We want to completely replace the contents of the grandparent block.
I find a workaround but it's a bit annoying 😅
base.html:
<html>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
articles.html:
{% extends "base.html" %}
{% block title %}{% block childtitle %}Articles{% endblock %}{% endblock %}
year.html:
{% extends "articles.html" %}
{% block childtitle %}Articles in {{ year }}{% endblock %}
Issue
Grandchild blocks do not replace the Parent/Grandparent blocks. Appears that inheritance is not working as expected.
Given
base.html
_latexmathbase.html
_latexmathinline.html
Expected
Expected the rendered page to contain
Stencil "latexmath_inline.html"
Actual Result
The rendered page instead contained
Stencil "latexmath_base.html"
Setup
The test harness that i'm working with is posted at VaporExamplesLab/eval-vapor-leaf-stencil