Skip to content

Commit

Permalink
Revert "Missing templates should raise exceptions."
Browse files Browse the repository at this point in the history
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 73cafe7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/View/StringTemplate.php
Expand Up @@ -16,7 +16,6 @@

use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\InstanceConfigTrait;
use RuntimeException;

/**
* Provides an interface for registering and inserting
Expand Down Expand Up @@ -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'];
Expand Down
19 changes: 3 additions & 16 deletions tests/TestCase/View/StringTemplateTest.php
Expand Up @@ -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);

Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 73cafe7

Please sign in to comment.