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: */
7:
8: namespace Nette\Latte;
9:
10: use Nette;
11:
12:
13: /**
14: * Templating engine Latte.
15: *
16: * @author David Grudl
17: */
18: class Engine extends Nette\Object
19: {
20: /** @var Parser */
21: private $parser;
22:
23: /** @var Compiler */
24: private $compiler;
25:
26:
27: public function __construct()
28: {
29: $this->parser = new Parser;
30: $this->compiler = new Compiler;
31: $this->compiler->defaultContentType = Compiler::CONTENT_XHTML;
32:
33: Macros\CoreMacros::install($this->compiler);
34: $this->compiler->addMacro('cache', new Macros\CacheMacro($this->compiler));
35: Macros\UIMacros::install($this->compiler);
36: Macros\FormMacros::install($this->compiler);
37: }
38:
39:
40: /**
41: * Invokes filter.
42: * @param string
43: * @return string
44: */
45: public function __invoke($s)
46: {
47: return $this->compiler->compile($this->parser->parse($s));
48: }
49:
50:
51: /**
52: * @return Parser
53: */
54: public function getParser()
55: {
56: return $this->parser;
57: }
58:
59:
60: /**
61: * @return Compiler
62: */
63: public function getCompiler()
64: {
65: return $this->compiler;
66: }
67:
68: }
69: