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

Support Complex Inheritance #60

Closed
shnhrrsn opened this issue Mar 6, 2016 · 3 comments
Closed

Support Complex Inheritance #60

shnhrrsn opened this issue Mar 6, 2016 · 3 comments
Labels

Comments

@shnhrrsn
Copy link
Contributor

shnhrrsn commented Mar 6, 2016

Inheritance only appears to work once, as soon as you extend twice it no longer inherits blocks from the root template.

Example:

master.stencil

<!DOCTYPE html>
<html>
    <body>
        <div class="content">
            {% block content %}{% endblock %}
        </div>
    </body>
</html>

app.stencil

{% extends "master.stencil" %}

welcome.stencil

{% extends "app.stencil" %}

{% block content %}
    Testing
{% endblock %}

When welcome.stencil is rendered, the HTML from master.stencil is rendered, but the content block overridden in welcome.stencil is completely ignored. Even if you redefine {% block content %}{% endblock %} in app.stencil it still gets ignored.

In addition to this, there should also be a way to render the contents of the parent block you’re overriding, so if we change the above templates:

app.stencil

{% extends "master.stencil" %}

{% block content %}Hello{% endblock %}

welcome.stencil

{% extends "app.stencil" %}

{% block content %}{{ parent() }} World{% endblock %}

The content block should render as "Hello World".

I'm unfamiliar with Django/Jinja, but Twig (which is based on those) supports both of these and an example can be found here: http://twigfiddle.com/box9s8

@kylef kylef added the bug label Mar 6, 2016
@kylef
Copy link
Collaborator

kylef commented Mar 9, 2016

Inheritance in Django/Jinja does certainly work multiple times, and I think it should in Stencil. This is a bug that it doesn't work. Will try taking a look over the weekend.

@kylef
Copy link
Collaborator

kylef commented Nov 27, 2016

@shnhrrsn I've added support for multiple-inheritance in 393dc88, I'll be adding support for rendering the super block shortly ({{ block.super }}).

@kylef
Copy link
Collaborator

kylef commented Dec 2, 2016

@shnhrrsn d75db24 adds support for using {{ block.super }} to render the parent block.

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

2 participants