Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Does Volt have parent() function like Twig?

Hi.

Layout a.volt

{% block stylesheets %}
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/united/bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block javascripts %}
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
{% endblock %}

Layout b.volt extends a.volt

{% block stylesheets %}
    <link href="some.min.css" rel="stylesheet">
{% endblock %}
{% block javascripts %}
    <script>
        alert('Hi!');
    </script>
{% endblock %}

In front page the result will be

HEADER
    <link href="some.min.css" rel="stylesheet">

FOOTER
    <script>
         alert('Hi!');
    </script>

But expected behavior, if parent() set somewhere, should be like this

Layout b.volt extends a.volt

{% block stylesheets %}
            {{ parent() }}
            <link href="some.min.css" rel="stylesheet">
{% endblock %}
{% block javascripts %}
            {{ parent() }}
            <script>
                alert('Hi!');
            </script>
{% endblock %}

Than in front page will next code

HEADER
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/united/bootstrap.min.css" rel="stylesheet">
    <link href="some.min.css" rel="stylesheet">

FOOTER
     <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
    <script>
        alert('Hi!');
    </script>

twig.sensiolabs.org/doc/functions/parent.html



793

It's not parent() it is super()