Blocks from included templates

44 views
Skip to first unread message

jklingsporn

unread,
Dec 23, 2015, 6:26:46 AM12/23/15
to Pebble Templating Engine
Hi,

when including another template which defines a block, is there a way to override the block?
Say I have a templateA.html like this:

<head>
    <title>{% block title %}Template A{% endblock title%}</title>
</head>


Then in templateB.html im including A like this

<!DOCTYPE html>
<html lang="en">
{% include 'templateA.html' %}
<body>
</body>
</html>

And finally, templateC.html is inheriting from B like this

{% extends 'templateB.html' %}
{% block title %}Template C{% endblock title%}

When I'm invoking now templateC.html the title of the page is "Template A" and not "Template C" as I think it should be.

jklingsporn

unread,
Dec 23, 2015, 6:29:41 AM12/23/15
to Pebble Templating Engine
Even when I modify templateB.html to this

<!DOCTYPE html>
<html lang="en">
{% include 'templateA.html' %}
{% block title %}Template B{% endblock title%}
<body>
</body>
</html>

and invoking B, the title will still be "Template A", however the body prints "Template B".

Maybe it is related to issue: https://github.com/mbosecke/pebble/issues/153

Mitchell Bösecke

unread,
Mar 8, 2016, 10:57:22 PM3/8/16
to Pebble Templating Engine
Sorry for the lack of response. For the record, it is not yet possible. Twig has a tag called embed which does what you're looking for; hopefully one day we'll get that implemented in Pebble too.
Reply all
Reply to author
Forward
0 new messages