Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow Cell::render() method to work with relative directories.
Refs #3945
  • Loading branch information
markstory committed Jul 23, 2014
1 parent 2959a17 commit e64e01a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/View/Cell.php
Expand Up @@ -134,10 +134,10 @@ public function __construct(Request $request = null, Response $response = null,
* @return void
*/
public function render($template = null) {
if ($template !== null) {
if ($template !== null && strpos($template, '/') === false) {
$template = Inflector::underscore($template);
}
if (empty($template)) {
if ($template === null) {
$template = $this->template;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase/View/CellTest.php
Expand Up @@ -168,6 +168,17 @@ public function testPluginCellAlternateTemplate() {
$this->assertContains('This is a translatable string', "{$cell}");
}

/**
* Test that plugin cells can render other view templates.
*
* @return void
*/
public function testPluginCellAlternateTemplateRenderParam() {
$cell = $this->View->cell('TestPlugin.Dummy::echoThis', ['msg' => 'hello world!']);
$result = $cell->render('../../Element/translate');
$this->assertContains('This is a translatable string', $result);
}

/**
* Tests that using an unexisting cell throws an exception.
*
Expand Down

0 comments on commit e64e01a

Please sign in to comment.