1: <?php
2:
3: /**
4: * This file is part of the Nette Framework.
5: *
6: * Copyright (c) 2004, 2010 David Grudl (http://davidgrudl.com)
7: *
8: * This source file is subject to the "Nette license", and/or
9: * GPL license. For more information please see http://nette.org
10: */
11:
12: namespace Nette\Latte;
13:
14: use Nette;
15:
16:
17:
18: /**
19: * Macro element node.
20: *
21: * @author David Grudl
22: */
23: class MacroNode extends Nette\Object
24: {
25: /** @var IMacro */
26: public $macro;
27:
28: /** @var string */
29: public $name;
30:
31: /** @var bool */
32: public $isEmpty = FALSE;
33:
34: /** @var string raw arguments */
35: public $args;
36:
37: /** @var string raw modifier */
38: public $modifiers;
39:
40: /** @var bool */
41: public $closing = FALSE;
42:
43: /** @var MacroTokenizer */
44: public $tokenizer;
45:
46: /** @var int @internal */
47: public $offset;
48:
49: /** @var MacroNode */
50: public $parentNode;
51:
52: /** @var string */
53: public $content;
54:
55: /** @var stdClass user data */
56: public $data;
57:
58: /** @var HtmlNode for n:attr macros */
59: public $htmlNode;
60:
61:
62:
63: public function __construct(IMacro $macro, $name, $args = NULL, $modifiers = NULL, MacroNode $parentNode = NULL, HtmlNode $htmlNode = NULL)
64: {
65: $this->macro = $macro;
66: $this->name = (string) $name;
67: $this->modifiers = (string) $modifiers;
68: $this->parentNode = $parentNode;
69: $this->htmlNode = $htmlNode;
70: $this->tokenizer = new MacroTokenizer($this->args);
71: $this->data = new \stdClass;
72: $this->setArgs($args);
73: }
74:
75:
76:
77: public function setArgs($args)
78: {
79: $this->args = (string) $args;
80: $this->tokenizer->tokenize($this->args);
81: }
82:
83:
84:
85: public function close($content)
86: {
87: $this->closing = TRUE;
88: $this->content = $content;
89: return $this->macro->nodeClosed($this);
90: }
91:
92: }
93: