M
M
Matvey Mamonov2015-06-29 15:33:11
Twig
Matvey Mamonov, 2015-06-29 15:33:11

Why doesn't {% parent %} work?

Why does it show this?


Uncaught exception 'Twig_Error_Syntax' with message 'Unexpected tag name "parent" (expecting closing tag for the "block" tag defined near line 3) in "view_post.tpl" at line 5' in /var/www/mamonov/vendor/twig /twig/lib/Twig/Parser.php:177 Stack trace: #0 true) #1 /var/www/mamonov/vendor/twig/twig/lib/Twig/Parser.php(191)...

glob.tpl
<!DOCTYPE html>
<html>
  <head>
    {% block head %}
      <link rel="stylesheet" href="">
      <meta charset="utf-8">
    {% endblock %}
  </head>
  <body>
    <header>
      <ul>
        <li>link</li>
        <li>link</li>
        <li>link</li>
        <li>link</li>
        <li>link</li>
      </ul>
    </header>
    <main>
      {% block main %}
      {% endblock %}
    </main>
    <footer>
      &copy; 2015 Matthew Mamonov
    </footer>
  </body>
</html>

view_post.tpl
{% extends "glob/glob.tpl" %}
{% block head %}
  {% parent %}
  <title>{{ name }}</title>
{% endblock %}
{% block main %}
  <h1>{{ name }}</h1>
  <p>{{ content }}</p>
  <div>
    <span>{{ author }}</span> <span>{{ date|upper }}</span>
  </div>
{% endblock %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sukherev, 2015-06-29
@eucalipt

{{ parent() }}
because function:
twig.sensiolabs.org/doc/functions/parent.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question