Skip to content

Commit

Permalink
Dev: fixed issue, can't register css/script from within twig views
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed May 4, 2017
1 parent 9b951c5 commit 5130596
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 0 additions & 11 deletions application/controllers/survey/index.php
Expand Up @@ -46,18 +46,7 @@ public function run()
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");

useFirebug();

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

// TODO: If we want to be able to add CSS/JS from twig file using CClientScript, $this->action() should return an HTML string, and ob_implicit_flush(false); should happen after it.
ob_implicit_flush(false);
$this->action();
ob_flush();
}

function action()
Expand Down
13 changes: 12 additions & 1 deletion application/core/LSETwigViewRenderer.php
Expand Up @@ -190,6 +190,17 @@ public function renderTemplateFromString( $line, $aDatas, $bReturn)
$oTwigTemplate = $twig->createTemplate($line);
$nvLine = $oTwigTemplate->render($aDatas, false);

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

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

Yii::app()->end();
}
}

0 comments on commit 5130596

Please sign in to comment.