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