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 LatteFilter extends Object
22: {
23: /** @var Parser */
24: private $parser;
25:
26: /** @var LatteCompiler */
27: private $compiler;
28:
29:
30: public function __construct()
31: {
32: $this->parser = new Parser;
33: $this->compiler = new LatteCompiler;
34: $this->compiler->defaultContentType = LatteCompiler::CONTENT_XHTML;
35:
36: CoreMacros::install($this->compiler);
37: $this->compiler->addMacro('cache', new CacheMacro($this->compiler));
38: UIMacros::install($this->compiler);
39: FormMacros::install($this->compiler);
40: }
41:
42:
43: /**
44: * Invokes filter.
45: * @param string
46: * @return string
47: */
48: public function __invoke($s)
49: {
50: return $this->compiler->compile($this->parser->parse($s));
51: }
52:
53:
54: /**
55: * @return Parser
56: */
57: public function getParser()
58: {
59: return $this->parser;
60: }
61:
62:
63: /**
64: * @return LatteCompiler
65: */
66: public function getCompiler()
67: {
68: return $this->compiler;
69: }
70:
71: }
72: