Skip to content

Commit b029722

Browse files
author
phalcon
committed
Fixing bug with partials in Mvc\View
1 parent 298fa34 commit b029722

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

unit-tests/ViewEnginesTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ public function __construct(Phalcon\Mvc\View $view, Phalcon\DI $di)
3434
parent::__construct($view, $di);
3535
}
3636

37-
public function render($path, $params)
37+
public function render($path, $params, $mustClean=false)
3838
{
3939
if (!isset($params['content'])) {
4040
$params['content'] = $this->_view->getContent();
4141
}
42-
$mustache = clone $this->_mustache;
43-
$content = $mustache->render(file_get_contents($path), $params);
44-
$this->_view->setContent($content);
42+
43+
$content = $this->_mustache->render(file_get_contents($path), $params);
44+
if ($mustClean) {
45+
$this->_view->setContent($content);
46+
} else {
47+
echo $content;
48+
}
4549
}
4650

4751
}
@@ -61,7 +65,7 @@ public function __construct(Phalcon\Mvc\View $view, Phalcon\DI $di)
6165
parent::__construct($view, $di);
6266
}
6367

64-
public function render($path, $params)
68+
public function render($path, $params, $mustClean=false)
6569
{
6670
$view = $this->_view;
6771
if (!isset($params['content'])) {
@@ -73,7 +77,12 @@ public function render($path, $params)
7377
}
7478

7579
$relativePath = str_replace($view->getViewsDir(), '', $path);
76-
$this->_view->setContent($this->_twig->render($relativePath, $params));
80+
$content = $this->_twig->render($relativePath, $params);
81+
if ($mustClean) {
82+
$this->_view->setContent($content);
83+
} else {
84+
echo $content;
85+
}
7786
}
7887

7988
}

0 commit comments

Comments
 (0)