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: if (method_exists('Latte\Engine', '__construct')) {
24: parent::__construct();
25: }
26: $this->getParser()->shortNoEscape = TRUE;
27: $this->addFilter('url', 'rawurlencode');
28: foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
29: $this->addFilter($name, 'Nette\Utils\Strings::' . $name);
30: }
31: }
32:
33:
34: public function __invoke($s)
35: {
36: trigger_error(__METHOD__ . '() is deprecated; use compile() instead.', E_USER_DEPRECATED);
37: return $this->setLoader(new Latte\Loaders\StringLoader)->compile($s);
38: }
39:
40:
41: public function getCompiler()
42: {
43: $compiler = parent::getCompiler();
44: if (!$this->fixed) {
45: $this->fixed = TRUE;
46: $compiler->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($compiler));
47: Nette\Bridges\ApplicationLatte\UIMacros::install($compiler);
48: Nette\Bridges\FormsLatte\FormMacros::install($compiler);
49: }
50: return $compiler;
51: }
52:
53:
54: public function & __get($name)
55: {
56: switch (strtolower($name)) {
57: case 'parser':
58: case 'compiler':
59: $method = 'get' . ucfirst($name);
60: trigger_error("Magic getters are deprecated. Use $method() method instead.", E_USER_DEPRECATED);
61: $return = $this->$method();
62: return $return;
63: }
64:
65: return parent::__get($name);
66: }
67:
68: }
69: