Skip to content

Commit

Permalink
Use proper module-dependent view suffix in renderScript view helper
Browse files Browse the repository at this point in the history
  • Loading branch information
xemlock committed Jan 3, 2019
1 parent 9212407 commit 547ef5b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/Zefram/View/Helper/RenderScript.php
Expand Up @@ -126,7 +126,7 @@ public function renderScript($script = null, $module = null, array $vars = null)

try {
$exception = null;
$result = $view->render($this->_getScriptName($script));
$result = $view->render($this->_getScriptName($script, $module));

} catch (Exception $exception) {
// will be re-thrown after cleanup
Expand Down Expand Up @@ -186,15 +186,16 @@ protected function _getViewRenderer()
* Ensure that given script has proper suffix (file extension)
*
* @param string $script
* @param string $module
* @return string
*/
protected function _getScriptName($script)
protected function _getScriptName($script, $module)
{
$viewRenderer = $this->_getViewRenderer();

// ensure script has proper suffix (extension)
if (strpos($viewRenderer->getViewScriptPathSpec(), ':suffix') !== false) {
$suffix = '.' . ltrim($viewRenderer->getViewSuffix(), '.');
if (strpos($viewRenderer->getViewScriptPathSpec($module), ':suffix') !== false) {
$suffix = '.' . ltrim($viewRenderer->getViewSuffix($module), '.');
if (substr($script, -strlen($suffix)) !== $suffix) {
$script .= $suffix;
}
Expand Down

0 comments on commit 547ef5b

Please sign in to comment.