From a6dc10c31ae78744ecd513263270f309651c42b0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Sep 2010 08:33:33 +0200 Subject: [PATCH] changed templating name notation Old notation: bundle:section:name.format:renderer (where both format and renderer are optional) New notation: bundle:section:name.format.renderer (where only format is optional) Valid new template names: Blog:Post:index.php, Blog:Post:index.xml.php The new notation is more explicit and put all templating engines on the same level (there is no more the concept of a "default" templating engine). Even if the notation changed, the semantic has not. So, the logical template name for the above examples is still 'index'. So, if you use a database loader for instance, the template name is 'index' and everything else are options. Upgrading current applications can be easily done by appending .php to each existing template name reference (in both controllers and templates), and changing :twig to .twig for Twig templates (for twig templates, you should also add .twig within templates themselves when referencing another Twig templates). --- .../Controller/DefaultController.php | 2 +- .../Controller/ExceptionController.php | 2 +- .../Resources/views/Exception/exception.php | 8 +- .../views/Exception/exception.xml.php | 4 +- .../Resources/views/Exception/layout.php | 2 +- .../Resources/views/Exception/traces.php | 2 +- .../Resources/views/Exception/traces.txt.php | 2 +- .../Resources/views/Exception/traces.xml.php | 2 +- .../FrameworkBundle/Templating/Engine.php | 33 +++---- .../Tests/Templating/EngineTest.php | 87 +++++++++++++++++++ .../Bundle/TwigBundle/Loader/Loader.php | 6 +- .../Controller/ExceptionController.php | 2 +- .../Controller/ProfilerController.php | 21 ++--- .../Resources/config/web_profiler.xml | 18 ++-- .../Resources/views/Profiler/index.php | 2 +- .../Resources/views/Profiler/layout.php | 2 +- .../Resources/views/Profiler/menu.php | 2 +- .../Resources/views/Profiler/notfound.php | 2 +- .../Resources/views/Profiler/panel.php | 2 +- .../views/Profiler/request_panel.php | 10 +-- .../Resources/views/Profiler/results.php | 2 +- 21 files changed, 150 insertions(+), 63 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/EngineTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php index 09f0ba647a..458b34fafd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php @@ -28,6 +28,6 @@ class DefaultController extends ContainerAware */ public function indexAction() { - return $this->container->get('templating')->renderResponse('FrameworkBundle:Default:index'); + return $this->container->get('templating')->renderResponse('FrameworkBundle:Default:index.php'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php index bced69e3fd..8960204f49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php @@ -43,7 +43,7 @@ class ExceptionController extends ContainerAware } $response = $this->container->get('templating')->renderResponse( - 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error'), + 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php'), array( 'exception' => new SafeDecorator($exception), 'logger' => $logger, diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php index 801668bcb9..733b9c3727 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php @@ -1,5 +1,5 @@ - extend('FrameworkBundle:Exception:layout') ?> + extend('FrameworkBundle:Exception:layout.php') ?>
@@ -27,10 +27,10 @@
- render('FrameworkBundle:Exception:traces', array('exception' => $exception, 'position' => 0, 'count' => $previousCount)) ?> + render('FrameworkBundle:Exception:traces.php', array('exception' => $exception, 'position' => 0, 'count' => $previousCount)) ?> getPreviouses() as $i => $previous): ?> - render('FrameworkBundle:Exception:traces', array('exception' => $previous, 'position' => $i + 1, 'count' => $previousCount)) ?> + render('FrameworkBundle:Exception:traces.php', array('exception' => $previous, 'position' => $i + 1, 'count' => $previousCount)) ?> @@ -43,7 +43,7 @@ diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php index c6b97cf9e0..06d8d8c46e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php @@ -1,12 +1,12 @@ ', $view->getCharset())."\n" ?> - render('FrameworkBundle:Exception:traces', array('exception' => $exception, 'position' => 0, 'count' => ($previousCount = count($exception->getPreviouses())))) ?> + render('FrameworkBundle:Exception:traces.php', array('exception' => $exception, 'position' => 0, 'count' => ($previousCount = count($exception->getPreviouses())))) ?> getPreviouses() as $i => $previous): ?> - render('FrameworkBundle:Exception:traces', array('exception' => $previous, 'position' => $i + 1, 'count' => $previousCount)) ?> + render('FrameworkBundle:Exception:traces.php', array('exception' => $previous, 'position' => $i + 1, 'count' => $previousCount)) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php index 35911d5bfd..a46aadcfb0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/layout.php @@ -8,7 +8,7 @@ body { font: 11px Verdana, Arial, sans-serif; color: #333 } .sf-exceptionreset, .sf-exceptionreset .block, .sf-exceptionreset #message { margin: auto } - render('FrameworkBundle:Exception:styles') ?> + render('FrameworkBundle:Exception:styles.php') ?>