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