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 NLatteFilter extends NObject
18: {
19: /** @var NParser */
20: private $parser;
21:
22: /** @var NLatteCompiler */
23: private $compiler;
24:
25:
26: public function __construct()
27: {
28: $this->parser = new NParser;
29: $this->compiler = new NLatteCompiler;
30: $this->compiler->defaultContentType = NLatteCompiler::CONTENT_XHTML;
31:
32: NCoreMacros::install($this->compiler);
33: $this->compiler->addMacro('cache', new NCacheMacro($this->compiler));
34: NUIMacros::install($this->compiler);
35: NFormMacros::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 NParser
52: */
53: public function getParser()
54: {
55: return $this->parser;
56: }
57:
58:
59: /**
60: * @return NLatteCompiler
61: */
62: public function getCompiler()
63: {
64: return $this->compiler;
65: }
66:
67: }
68: