Skip to content

Commit

Permalink
Nette\Latte\Engine: loads UIMacros, FormMacros and CacheMacro before …
Browse files Browse the repository at this point in the history
…onCompile is invoked
  • Loading branch information
dg committed Apr 28, 2014
1 parent e742ad6 commit a46a9d7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Nette/deprecated/Latte/Engine.php
Expand Up @@ -16,16 +16,11 @@
*/
class Engine extends Latte\Engine
{
private $fixed = FALSE;

public function __construct()
{
$this->onCompile[] = function($latte) {
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
Nette\Bridges\ApplicationLatte\UIMacros::install($latte->getCompiler());
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
};

$this->getParser()->shortNoEscape = TRUE;
$this->addFilter('url', 'rawurlencode');
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
$this->addFilter($name, 'Nette\Utils\Strings::' . $name);
Expand All @@ -40,6 +35,19 @@ public function __invoke($s)
}


public function getCompiler()
{
$compiler = parent::getCompiler();
if (!$this->fixed) {
$this->fixed = TRUE;
$compiler->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($compiler));
Nette\Bridges\ApplicationLatte\UIMacros::install($compiler);
Nette\Bridges\FormsLatte\FormMacros::install($compiler);
}
return $compiler;
}


public function & __get($name)
{
switch (strtolower($name)) {
Expand Down

0 comments on commit a46a9d7

Please sign in to comment.