Skip to content
Permalink
Browse files

Revert "Missing templates should raise exceptions."

This reverts commit 64ec05c.
I accidentally committed this to the wrong branch. And we have force
push disabled.
  • Loading branch information...
markstory committed Mar 28, 2016
1 parent 64ec05c commit 73cafe7c7d5d32014bae8f5eddfb83dfccafdf48
Showing with 7 additions and 18 deletions.
  1. +4 −2 src/View/StringTemplate.php
  2. +3 −16 tests/TestCase/View/StringTemplateTest.php
@@ -16,7 +16,6 @@
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\InstanceConfigTrait;
use RuntimeException;
/**
* Provides an interface for registering and inserting
@@ -225,9 +224,12 @@ public function remove($name)
public function format($name, array $data)
{
if (!isset($this->_compiled[$name])) {
throw new RuntimeException("Cannot find template named '$name'.");
return null;
}
list($template, $placeholders) = $this->_compiled[$name];
if ($template === null) {
return null;
}
if (isset($data['templateVars'])) {
$data += $data['templateVars'];
@@ -95,6 +95,9 @@ public function testFormat()
];
$this->template->add($templates);
$result = $this->template->format('not there', []);
$this->assertNull($result);
$result = $this->template->format('text', ['text' => '']);
$this->assertSame('', $result);
@@ -139,22 +142,6 @@ public function testFormatArrayData()
$this->assertEquals('<a href="/">exampletext</a>', $result);
}
/**
* Test formatting a missing template.
*
* @expectedException RuntimeException
* @expectedExceptionMessage Cannot find template named 'missing'
* @return void
*/
public function testFormatMissingTemplate()
{
$templates = [
'text' => '{{text}}',
];
$this->template->add($templates);
$this->template->format('missing', ['text' => 'missing']);
}
/**
* Test loading templates files in the app.
*

0 comments on commit 73cafe7

Please sign in to comment.
You can’t perform that action at this time.