1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004 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 NLatteFilter extends NObject
22: {
23: /** @var NParser */
24: private $parser;
25:
26: /** @var NLatteCompiler */
27: private $compiler;
28:
29:
30:
31: public function __construct()
32: {
33: $this->parser = new NParser;
34: $this->compiler = new NLatteCompiler;
35: $this->compiler->defaultContentType = NLatteCompiler::CONTENT_XHTML;
36:
37: NCoreMacros::install($this->compiler);
38: $this->compiler->addMacro('cache', new NCacheMacro($this->compiler));
39: NUIMacros::install($this->compiler);
40: NFormMacros::install($this->compiler);
41: }
42:
43:
44:
45: /**
46: * Invokes filter.
47: * @param string
48: * @return string
49: */
50: public function __invoke($s)
51: {
52: return $this->compiler->compile($this->parser->parse($s));
53: }
54:
55:
56:
57: /**
58: * @return NParser
59: */
60: public function getParser()
61: {
62: return $this->parser;
63: }
64:
65:
66:
67: /**
68: * @return NLatteCompiler
69: */
70: public function getCompiler()
71: {
72: return $this->compiler;
73: }
74:
75: }
76: