1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
6: * @package Nette\Latte
7: */
8:
9:
10:
11: /**
12: * Templating engine Latte.
13: *
14: * @author David Grudl
15: * @package Nette\Latte
16: */
17: class LatteFilter extends Object
18: {
19: /** @var Parser */
20: private $parser;
21:
22: /** @var LatteCompiler */
23: private $compiler;
24:
25:
26: public function __construct()
27: {
28: $this->parser = new Parser;
29: $this->compiler = new LatteCompiler;
30: $this->compiler->defaultContentType = LatteCompiler::CONTENT_XHTML;
31:
32: CoreMacros::install($this->compiler);
33: $this->compiler->addMacro('cache', new CacheMacro($this->compiler));
34: UIMacros::install($this->compiler);
35: FormMacros::install($this->compiler);
36: }
37:
38:
39: /**
40: * Invokes filter.
41: * @param string
42: * @return string
43: */
44: public function __invoke($s)
45: {
46: return $this->compiler->compile($this->parser->parse($s));
47: }
48:
49:
50: /**
51: * @return Parser
52: */
53: public function getParser()
54: {
55: return $this->parser;
56: }
57:
58:
59: /**
60: * @return LatteCompiler
61: */
62: public function getCompiler()
63: {
64: return $this->compiler;
65: }
66:
67: }
68: