Skip to content

Commit 7b3b060

Browse files
author
Phalcon
committed
Merge pull request #388 from phalcon/0.9.0
0.9.0
2 parents b874305 + f65b3d3 commit 7b3b060

File tree

5 files changed

+23
-27
lines changed

5 files changed

+23
-27
lines changed

build/32bits/phalcon.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
5863058630
PHP_METHOD(Phalcon_Mvc_View, partial){
5863158631

5863258632
zval *partial_path, *zfalse, *partials_dir, *real_path;
58633-
zval *engines, *content;
58633+
zval *engines;
5863458634

5863558635
PHALCON_MM_GROW();
5863658636

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

5864758647
PHALCON_INIT_VAR(real_path);
5864858648
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
58649-
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);
5865058649

5865158650
PHALCON_INIT_VAR(engines);
5865258651
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
5865358652
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);
5865458653

58655-
PHALCON_OBS_VAR(content);
58656-
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
58657-
RETURN_CCTOR(content);
58654+
PHALCON_MM_RESTORE();
5865858655
}
5865958656

5866058657
PHP_METHOD(Phalcon_Mvc_View, getRender){

build/64bits/phalcon.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73532,7 +73532,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
7353273532
PHP_METHOD(Phalcon_Mvc_View, partial){
7353373533

7353473534
zval *partial_path, *zfalse, *partials_dir, *real_path;
73535-
zval *engines, *content;
73535+
zval *engines;
7353673536

7353773537
PHALCON_MM_GROW();
7353873538

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

7354973549
PHALCON_INIT_VAR(real_path);
7355073550
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
73551-
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);
7355273551

7355373552
PHALCON_INIT_VAR(engines);
7355473553
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
7355573554
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);
7355673555

73557-
PHALCON_OBS_VAR(content);
73558-
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
73559-
RETURN_CCTOR(content);
73556+
PHALCON_MM_RESTORE();
7356073557
}
7356173558

7356273559
PHP_METHOD(Phalcon_Mvc_View, getRender){

build/safe/phalcon.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
5863058630
PHP_METHOD(Phalcon_Mvc_View, partial){
5863158631

5863258632
zval *partial_path, *zfalse, *partials_dir, *real_path;
58633-
zval *engines, *content;
58633+
zval *engines;
5863458634

5863558635
PHALCON_MM_GROW();
5863658636

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

5864758647
PHALCON_INIT_VAR(real_path);
5864858648
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
58649-
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);
5865058649

5865158650
PHALCON_INIT_VAR(engines);
5865258651
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
5865358652
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);
5865458653

58655-
PHALCON_OBS_VAR(content);
58656-
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
58657-
RETURN_CCTOR(content);
58654+
PHALCON_MM_RESTORE();
5865858655
}
5865958656

5866058657
PHP_METHOD(Phalcon_Mvc_View, getRender){

ext/mvc/view.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,12 +1324,11 @@ PHP_METHOD(Phalcon_Mvc_View, pick){
13241324
* </code>
13251325
*
13261326
* @param string $partialPath
1327-
* @return string
13281327
*/
13291328
PHP_METHOD(Phalcon_Mvc_View, partial){
13301329

13311330
zval *partial_path, *zfalse, *partials_dir, *real_path;
1332-
zval *engines, *content;
1331+
zval *engines;
13331332

13341333
PHALCON_MM_GROW();
13351334

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

13461345
PHALCON_INIT_VAR(real_path);
13471346
PHALCON_CONCAT_VV(real_path, partials_dir, partial_path);
1348-
phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC);
13491347

13501348
PHALCON_INIT_VAR(engines);
13511349
PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines");
13521350
PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse);
13531351

1354-
PHALCON_OBS_VAR(content);
1355-
phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC);
1356-
RETURN_CCTOR(content);
1352+
PHALCON_MM_RESTORE();
13571353
}
13581354

13591355
/**

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)