Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from falmp/render-optimization
Browse files Browse the repository at this point in the history
Removed unnecessary appendData(), the Slim render() already does that.
  • Loading branch information
yaworsw committed Nov 8, 2013
2 parents b046e4c + 68d7e9c commit c3169c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
7 changes: 2 additions & 5 deletions src/SlimController/SlimController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,14 @@ public function __construct(\Slim\Slim &$app)
* @param string $template Name of the template to be rendererd
* @param array $args Args for view
*/
protected function render($template, $args = null)
protected function render($template, $args = array())
{
if (!is_null($args)) {
$this->app->view()->appendData($args);
}
if (!is_null($this->renderTemplateSuffix)
&& !preg_match('/\.' . $this->renderTemplateSuffix . '$/', $template)
) {
$template .= '.' . $this->renderTemplateSuffix;
}
$this->app->render($template);
$this->app->render($template, $args);
}

/**
Expand Down
12 changes: 2 additions & 10 deletions tests/SlimController/Tests/SlimControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,9 @@ public function testControllerConfigParamsAreUsed()
public function testRenderingWorksFine()
{
$this->assertDefaultConstruction();
$view = m::mock();
$this->slim->shouldReceive('view')
->once()
->withNoArgs()
->andReturn($view);
$view->shouldReceive('appendData')
->once()
->with(array('foo' => 'orotound', 'bar' => 'grandios'));
$this->slim->shouldReceive('render')
->once()
->with('rendertest.Suffix');
->with('rendertest.Suffix', array('foo' => 'orotound', 'bar' => 'grandios'));

$controller = new TestController($this->slim);
$controller->renderAction();
Expand Down Expand Up @@ -282,4 +274,4 @@ protected function assertDefaultConstruction($suffix = 'Suffix', $paramPrefix =
->andReturn($cleanupParams);
}

}
}

0 comments on commit c3169c5

Please sign in to comment.