1: <?php
2:
3: /**
4: * This file is part of the Latte (https://latte.nette.org)
5: * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Latte;
9:
10:
11: /**
12: * Macro element node.
13: */
14: class MacroNode
15: {
16: use Strict;
17:
18: const PREFIX_INNER = 'inner',
19: PREFIX_TAG = 'tag',
20: PREFIX_NONE = 'none';
21:
22: /** @var IMacro */
23: public $macro;
24:
25: /** @var string */
26: public $name;
27:
28: /** @var bool */
29: public $empty = false;
30:
31: /** @deprecated */
32: public $isEmpty;
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 bool has output? */
44: public $replaced;
45:
46: /** @var MacroTokens */
47: public $tokenizer;
48:
49: /** @var MacroNode */
50: public $parentNode;
51:
52: /** @var string */
53: public $openingCode;
54:
55: /** @var string */
56: public $closingCode;
57:
58: /** @var string */
59: public $attrCode;
60:
61: /** @var string */
62: public $content;
63:
64: /** @var string */
65: public $innerContent;
66:
67: /** @var \stdClass user data */
68: public $data;
69:
70: /** @var HtmlNode closest HTML node */
71: public $htmlNode;
72:
73: /** @var array [contentType, context] */
74: public $context;
75:
76: /** @var string indicates n:attribute macro and type of prefix (PREFIX_INNER, PREFIX_TAG, PREFIX_NONE) */
77: public $prefix;
78:
79: /** @var int position of start tag in source template */
80: public $startLine;
81:
82: /** @var int position of end tag in source template */
83: public $endLine;
84:
85: /** @internal */
86: public $saved;
87:
88:
89: public function __construct(IMacro $macro, $name, $args = null, $modifiers = null, self $parentNode = null, HtmlNode $htmlNode = null, $prefix = null)
90: {
91: $this->macro = $macro;
92: $this->name = (string) $name;
93: $this->modifiers = (string) $modifiers;
94: $this->parentNode = $parentNode;
95: $this->htmlNode = $htmlNode;
96: $this->prefix = $prefix;
97: $this->data = new \stdClass;
98: $this->isEmpty = &$this->empty;
99: $this->setArgs($args);
100: }
101:
102:
103: public function setArgs($args)
104: {
105: $this->args = (string) $args;
106: $this->tokenizer = new MacroTokens($this->args);
107: }
108:
109:
110: public function getNotation()
111: {
112: return $this->prefix
113: ? Parser::N_PREFIX . ($this->prefix === self::PREFIX_NONE ? '' : $this->prefix . '-') . $this->name
114: : '{' . $this->name . '}';
115: }
116: }
117: