1: <?php
 2: 
 3:  4:  5:  6: 
 7: 
 8: namespace Nette\Latte;
 9: 
10: use Nette;
11: use Latte;
12: 
13: 
14: 15: 16: 
17: class Engine extends Latte\Engine
18: {
19:     private $fixed = FALSE;
20: 
21:     public function __construct()
22:     {
23:         $this->getParser()->shortNoEscape = TRUE;
24:         $this->addFilter('url', 'rawurlencode');
25:         foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
26:             $this->addFilter($name, 'Nette\Utils\Strings::' . $name);
27:         }
28:     }
29: 
30: 
31:     public function __invoke($s)
32:     {
33:         trigger_error(__METHOD__ . '() is deprecated; use compile() instead.', E_USER_DEPRECATED);
34:         return $this->setLoader(new Latte\Loaders\StringLoader)->compile($s);
35:     }
36: 
37: 
38:     public function getCompiler()
39:     {
40:         $compiler = parent::getCompiler();
41:         if (!$this->fixed) {
42:             $this->fixed = TRUE;
43:             $compiler->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($compiler));
44:             Nette\Bridges\ApplicationLatte\UIMacros::install($compiler);
45:             Nette\Bridges\FormsLatte\FormMacros::install($compiler);
46:         }
47:         return $compiler;
48:     }
49: 
50: 
51:     public function & __get($name)
52:     {
53:         switch (strtolower($name)) {
54:             case 'parser':
55:             case 'compiler':
56:                 $method = 'get' . ucfirst($name);
57:                 trigger_error("Magic getters are deprecated. Use $method() method instead.", E_USER_DEPRECATED);
58:                 $return = $this->$method(); 
59:                 return $return;
60:         }
61: 
62:         return parent::__get($name);
63:     }
64: 
65: }
66: