W ramach nauki pisze prosty blog.
W moim kontrolerze renderuje widok z listą postów - wszystko jest ok.
Postanowiłem dać jakiś główny szablon, w tym celu stworzyłem plik layout.html.twig w folderze src/Milek/BlogBundle/Resources/views/ - jego zawartość:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta name="author" content="Luka Cvrk" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>INTERACTIVE MEDIA using media to broadcast content</title> </head> <body id="home"> {% block content %} {% endblock %} </body> </html>
zawartość pliku src/Milek/BlogBundle/Resources/views/Post/index.html.twig:
{# src/Milek/BlogBundle/Resources/views/Post/index.html.twig #} {% extends "MilekBlogBundle::layout.html.twig" %} {% block content %} {% for post in posts %} <div class="post"> <div class="header"><a href="{{ path('post_show', { 'slug': post.getSlug() }) }}">{{ post.getTitle() }}</a></div> <div>{{ post.getContent() }}</div> </div> {% endfor %} {% endblock %}
A to treść wyjątku:
Cytat
An exception has been thrown during the rendering of a template ("Route "_wdt" does not exist.") in WebProfilerBundle:Profiler:toolbar_js.html.twig at line 11.
Sprawa jest o tyle dziwna, że gdy usunę z pliku layout.html.twig dwie ostatnie linie, to wszystko jest ok.
Ok - poradziłem sobie. Wystarczyło w pliku routing_dev.yml dać kod który usunąłem wcześniej, czyli:
Kod
_assetic:
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml