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: */
11:
12: namespace Nette\Latte;
13:
14: use Nette;
15:
16:
17:
18: /**
19: * Templating engine Latte.
20: *
21: * @author David Grudl
22: */
23: class Engine extends Nette\Object
24: {
25: /** @var Parser */
26: public $parser;
27:
28:
29:
30: public function __construct()
31: {
32: $this->parser = new Parser;
33: Macros\CoreMacros::install($this->parser);
34: $this->parser->addMacro('cache', new Macros\CacheMacro($this->parser));
35: Macros\UIMacros::install($this->parser);
36: Macros\FormMacros::install($this->parser);
37: }
38:
39:
40:
41: /**
42: * Invokes filter.
43: * @param string
44: * @return string
45: */
46: public function __invoke($s)
47: {
48: $this->parser->context = array(Parser::CONTEXT_TEXT);
49: $this->parser->setDelimiters('\\{(?![\\s\'"{}])', '\\}');
50: return $this->parser->parse($s);
51: }
52:
53: }
54: