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