Skip to content

Commit

Permalink
Merge pull request #388 from phalcon/0.9.0
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
Phalcon committed Feb 5, 2013
2 parents b874305 + f65b3d3 commit 7b3b060
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
7 changes: 2 additions & 5 deletions build/32bits/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
PHP_METHOD(Phalcon_Mvc_View, partial){

zval *partial_path, *zfalse, *partials_dir, *real_path;
zval *engines, *content;
zval *engines;

PHALCON_MM_GROW();

Expand All @@ -58646,15 +58646,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){

PHALCON_INIT_VAR(real_path);
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);

PHALCON_INIT_VAR(engines);
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);

PHALCON_OBS_VAR(content);
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
RETURN_CCTOR(content);
PHALCON_MM_RESTORE();
}

PHP_METHOD(Phalcon_Mvc_View, getRender){
Expand Down
7 changes: 2 additions & 5 deletions build/64bits/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -73532,7 +73532,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
PHP_METHOD(Phalcon_Mvc_View, partial){

zval *partial_path, *zfalse, *partials_dir, *real_path;
zval *engines, *content;
zval *engines;

PHALCON_MM_GROW();

Expand All @@ -73548,15 +73548,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){

PHALCON_INIT_VAR(real_path);
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);

PHALCON_INIT_VAR(engines);
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);

PHALCON_OBS_VAR(content);
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
RETURN_CCTOR(content);
PHALCON_MM_RESTORE();
}

PHP_METHOD(Phalcon_Mvc_View, getRender){
Expand Down
7 changes: 2 additions & 5 deletions build/safe/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
PHP_METHOD(Phalcon_Mvc_View, partial){

zval *partial_path, *zfalse, *partials_dir, *real_path;
zval *engines, *content;
zval *engines;

PHALCON_MM_GROW();

Expand All @@ -58646,15 +58646,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){

PHALCON_INIT_VAR(real_path);
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);

PHALCON_INIT_VAR(engines);
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);

PHALCON_OBS_VAR(content);
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
RETURN_CCTOR(content);
PHALCON_MM_RESTORE();
}

PHP_METHOD(Phalcon_Mvc_View, getRender){
Expand Down
8 changes: 2 additions & 6 deletions ext/mvc/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,12 +1324,11 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
* </code>
*
* @param string $partialPath
* @return string
*/
PHP_METHOD(Phalcon_Mvc_View, partial){

zval *partial_path, *zfalse, *partials_dir, *real_path;
zval *engines, *content;
zval *engines;

PHALCON_MM_GROW();

Expand All @@ -1345,15 +1344,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){

PHALCON_INIT_VAR(real_path);
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);

PHALCON_INIT_VAR(engines);
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);

PHALCON_OBS_VAR(content);
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
RETURN_CCTOR(content);
PHALCON_MM_RESTORE();
}

/**
Expand Down
21 changes: 15 additions & 6 deletions unit-tests/ViewEnginesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ public function __construct(Phalcon\Mvc\View $view, Phalcon\DI $di)
parent::__construct($view, $di);
}

public function render($path, $params)
public function render($path, $params, $mustClean=false)
{
if (!isset($params['content'])) {
$params['content'] = $this->_view->getContent();
}
$mustache = clone $this->_mustache;
$content = $mustache->render(file_get_contents($path), $params);
$this->_view->setContent($content);

$content = $this->_mustache->render(file_get_contents($path), $params);
if ($mustClean) {
$this->_view->setContent($content);
} else {
echo $content;
}
}

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

public function render($path, $params)
public function render($path, $params, $mustClean=false)
{
$view = $this->_view;
if (!isset($params['content'])) {
Expand All @@ -73,7 +77,12 @@ public function render($path, $params)
}

$relativePath = str_replace($view->getViewsDir(), '', $path);
$this->_view->setContent($this->_twig->render($relativePath, $params));
$content = $this->_twig->render($relativePath, $params);
if ($mustClean) {
$this->_view->setContent($content);
} else {
echo $content;
}
}

}
Expand Down

0 comments on commit 7b3b060

Please sign in to comment.