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.

Volt rendering <head> content into <body>

Layout consists of following: main.volt:

 <!DOCTYPE html>
  <html>
  <head>
    {% block head %}
    <link...
    <script ...
    {% endblock %}
    <title>{% block title %}{% endblock %}</title>
  </head>
  <body>
    <div id="content">
      {% block content %}{% endblock %}
    </div>
  </body>
  </html>

And the file extending the template: requirements/index.volt

{% extends 'layouts/main.volt' %}
{% block head %}
  {{ super() }}
{% endblock %}
{% block content %}
  <p>I am in content</p>
{% endblock %}

However, the end result is the following:

<!DOCTYPE html>
<html>
<head>
    <title>Phalcon PHP Framework</title><!-- Where did this come from? -->
</head>
<body>
  <!-- Everything in <head> is dumped here -->
  <link...
  <script..
  <title></title>
  <div id="content">
    <p>I am in content</p>
  </div>
</body>
</html>

Am I doing something wrong? Why is everything being dumped into <head> ? Thanks

UPDATE: Project path image Folder Structure

(Ignore main_wrap.volt, it ain't used)



190
Accepted
answer

You're using both the automatic include behaviour and manually extending a view.

views/index.volt will be included, and the result of rendering views/controller/action.volt (with views/layouts/main.volt) will be placed into views/index.volt where the content() call is.

Thank you ! I was unaware that views/index.volt was being extended, and was thus getting intermingled with the manual 'extends' call in requirements/index.volt.