1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\Latte
11: */
12:
13:
14:
15: /**
16: * Templating engine Latte.
17: *
18: * @author David Grudl
19: * @package Nette\Latte
20: */
21: class LatteFilter extends Object
22: {
23: /** @var Parser */
24: public $parser;
25:
26:
27:
28: public function __construct()
29: {
30: $this->parser = new Parser;
31: CoreMacros::install($this->parser);
32: $this->parser->addMacro('cache', new CacheMacro($this->parser));
33: UIMacros::install($this->parser);
34: FormMacros::install($this->parser);
35: }
36:
37:
38:
39: /**
40: * Invokes filter.
41: * @param string
42: * @return string
43: */
44: public function __invoke($s)
45: {
46: $this->parser->context = array(Parser::CONTEXT_TEXT);
47: $this->parser->setDelimiters('\\{(?![\\s\'"{}])', '\\}');
48: return $this->parser->parse($s);
49: }
50:
51: }
52: