0
votes

Is there any way to use multiple inheritance in PhalconPHP Volt? I'd like to do something like that:

// index.volt

<!DOCTYPE html>
<html>

  <head>
   ...
  </head>

  <body>
   {% block content %}{% endblock %}
  </body>

</html>

Next:

// layout.volt

{% extends 'index.volt' %}

{% block content %}
  <div class='header'><div>
    {% block actionContent %}{% endblock %}
  <div class='footer'><div>
{% endblock %}

And then:

// actionView.volt

{% extends 'layout.volt' %}

{% block actionContent %}
   Lorem Ipsum
{% endblock %}

It doesn't work because of Embedding blocks into other blocks is not supported...

I very want resolve this problem. Is it possible?

2
No it's not supported. Use macros and partials for code re-use. - yogur

2 Answers

1
votes

This is not supported yet. But over on Github I see there are two tickets open for this issue:

[VOLT] Support for embedding blocks into other blocks

https://github.com/phalcon/cphalcon/issues/329

Volt parser embedding block error

https://github.com/phalcon/cphalcon/issues/12846

Might be a good idea to bump one of those issues to see if there has been an update.

0
votes

The only way I see here is instead of extending parent volts, you can include the children. That is supported.

// layout.volt

{% extends 'index.volt' %}

{% block content %}
  <div class='header'><div>
    {% include 'actionView.volt' %}
  <div class='footer'><div>
{% endblock %}

and

// actionView.volt
Lorem Ipsum