1: <?php
2:
3: /**
4: * This file is part of the Nette Framework.
5: *
6: * Copyright (c) 2004 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: const PREFIX_INNER = 'inner',
26: PREFIX_TAG = 'tag';
27:
28: /** @var IMacro */
29: public $macro;
30:
31: /** @var string */
32: public $name;
33:
34: /** @var bool */
35: public $isEmpty = FALSE;
36:
37: /** @var string raw arguments */
38: public $args;
39:
40: /** @var string raw modifier */
41: public $modifiers;
42:
43: /** @var bool */
44: public $closing = FALSE;
45:
46: /** @var MacroTokenizer */
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 \stdClass user data */
65: public $data;
66:
67: /** @var HtmlNode for n:attr macros */
68: public $htmlNode;
69:
70: /** @var string for n:attr macros (NULL, PREFIX_INNER, PREFIX_TAG) */
71: public $prefix;
72:
73: public $saved;
74:
75:
76:
77: public function __construct(IMacro $macro, $name, $args = NULL, $modifiers = NULL, MacroNode $parentNode = NULL, HtmlNode $htmlNode = NULL, $prefix = NULL)
78: {
79: $this->macro = $macro;
80: $this->name = (string) $name;
81: $this->modifiers = (string) $modifiers;
82: $this->parentNode = $parentNode;
83: $this->htmlNode = $htmlNode;
84: $this->prefix = $prefix;
85: $this->tokenizer = new MacroTokenizer($this->args);
86: $this->data = new \stdClass;
87: $this->setArgs($args);
88: }
89:
90:
91:
92: public function setArgs($args)
93: {
94: $this->args = (string) $args;
95: $this->tokenizer->tokenize($this->args);
96: }
97:
98: }
99: