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: * Macro element node.
19: *
20: * @author David Grudl
21: */
22: class MacroNode extends Nette\Object
23: {
24: const PREFIX_INNER = 'inner',
25: PREFIX_TAG = 'tag';
26:
27: /** @var IMacro */
28: public $macro;
29:
30: /** @var string */
31: public $name;
32:
33: /** @var bool */
34: public $isEmpty = FALSE;
35:
36: /** @var string raw arguments */
37: public $args;
38:
39: /** @var string raw modifier */
40: public $modifiers;
41:
42: /** @var bool */
43: public $closing = FALSE;
44:
45: /** @var MacroTokenizer */
46: public $tokenizer;
47:
48: /** @var MacroNode */
49: public $parentNode;
50:
51: /** @var string */
52: public $openingCode;
53:
54: /** @var string */
55: public $closingCode;
56:
57: /** @var string */
58: public $attrCode;
59:
60: /** @var string */
61: public $content;
62:
63: /** @var \stdClass user data */
64: public $data;
65:
66: /** @var HtmlNode for n:attr macros */
67: public $htmlNode;
68:
69: /** @var string for n:attr macros (NULL, PREFIX_INNER, PREFIX_TAG) */
70: public $prefix;
71:
72: public $saved;
73:
74:
75: public function __construct(IMacro $macro, $name, $args = NULL, $modifiers = NULL, MacroNode $parentNode = NULL, HtmlNode $htmlNode = NULL, $prefix = NULL)
76: {
77: $this->macro = $macro;
78: $this->name = (string) $name;
79: $this->modifiers = (string) $modifiers;
80: $this->parentNode = $parentNode;
81: $this->htmlNode = $htmlNode;
82: $this->prefix = $prefix;
83: $this->tokenizer = new MacroTokenizer($this->args);
84: $this->data = new \stdClass;
85: $this->setArgs($args);
86: }
87:
88:
89: public function setArgs($args)
90: {
91: $this->args = (string) $args;
92: $this->tokenizer->tokenize($this->args);
93: }
94:
95: }
96: