forked from symfony/symfony
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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).
- Loading branch information
Showing
21 changed files
with
150 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.txt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php if (count($exception->getTrace())): ?> | ||
<?php foreach ($exception->getTrace() as $i => $trace): ?> | ||
<?php echo $view->render('FrameworkBundle:Exception:trace.txt', array('i' => $i, 'trace' => $trace)) ?> | ||
<?php echo $view->render('FrameworkBundle:Exception:trace.txt.php', array('i' => $i, 'trace' => $trace)) ?> | ||
|
||
<?php endforeach; ?> | ||
<?php endif;?> |
2 changes: 1 addition & 1 deletion
2
src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.xml.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/Symfony/Bundle/FrameworkBundle/Tests/Templating/EngineTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase; | ||
use Symfony\Bundle\FrameworkBundle\Templating\Engine; | ||
|
||
class EngineTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getSplitTemplateNameTests | ||
*/ | ||
public function testSplitTemplateName($name, $parameters) | ||
{ | ||
$engine = new Engine($this->getContainerMock(), $this->getLoaderMock()); | ||
|
||
$this->assertEquals($parameters, $engine->splitTemplateName($name)); | ||
} | ||
|
||
public function getSplitTemplateNameTests() | ||
{ | ||
return array( | ||
array('BlogBundle:Post:index.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => ''))), | ||
array('BlogBundle:Post:index.twig', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => ''))), | ||
array('BlogBundle:Post:index.xml.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'xml'))), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider getSplitTemplateNameInvalidTests | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testSplitTemplateNameInvalid($name) | ||
{ | ||
$engine = new Engine($this->getContainerMock(), $this->getLoaderMock()); | ||
|
||
$engine->splitTemplateName($name); | ||
} | ||
|
||
public function getSplitTemplateNameInvalidTests() | ||
{ | ||
return array( | ||
array('BlogBundle:Post:index'), | ||
array('BlogBundle:Post'), | ||
array('BlogBundle:Post:foo:bar'), | ||
array('BlogBundle:Post:index.foo.bar.foobar'), | ||
); | ||
} | ||
|
||
protected function getContainerMock() | ||
{ | ||
$request = $this->getMock('Symfony\Component\HttpFoundation\Request'); | ||
$request | ||
->expects($this->any()) | ||
->method('getRequestFormat') | ||
->will($this->returnValue('html')) | ||
; | ||
|
||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); | ||
$container | ||
->expects($this->exactly(2)) | ||
->method('findTaggedServiceIds') | ||
->will($this->returnValue(array())) | ||
; | ||
$container | ||
->expects($this->any()) | ||
->method('get') | ||
->will($this->returnValue($request)) | ||
; | ||
|
||
return $container; | ||
} | ||
|
||
protected function getLoaderMock() | ||
{ | ||
return $this->getMock('Symfony\Component\Templating\Loader\LoaderInterface'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<?php $view->extend('WebProfilerBundle:Profiler:layout') ?> | ||
<?php $view->extend('WebProfilerBundle:Profiler:layout.php') ?> | ||
|
||
<?php echo $view->render($template, array('data' => $collector)) ?> |
2 changes: 1 addition & 1 deletion
2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.