Skip to content

Commit

Permalink
Dev: added return mode to twig rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jun 2, 2017
1 parent 1cab15f commit 6111189
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions application/core/LSETwigViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ public function renderTemplateFromFile($sView, $aDatas, $bReturn)
{
$oTemplate = $this->getTemplateForView($sView);
$line = file_get_contents($oTemplate->viewPath.$sView);
$this->renderTemplateFromString( $line, $aDatas, $bReturn);
$result = $this->renderTemplateFromString( $line, $aDatas, $bReturn);
if ($bReturn){
return $result;
}
}

private function getTemplateForView($sView)
Expand Down Expand Up @@ -206,17 +209,21 @@ public function renderTemplateFromString( $line, $aDatas, $bReturn)
$oTwigTemplate = $twig->createTemplate($line);
$nvLine = $oTwigTemplate->render($aDatas, false);

ob_start(function($buffer, $phase)
{
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
if (!$bReturn){
ob_start(function($buffer, $phase)
{
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});

ob_implicit_flush(false);
echo $nvLine;
ob_flush();
ob_implicit_flush(false);
echo $nvLine;
ob_flush();

Yii::app()->end();
Yii::app()->end();
}else{
return $nvLine;
}
}
}

0 comments on commit 6111189

Please sign in to comment.