@@ -49,21 +49,22 @@ public static function install(Latte\Compiler $compiler)
49
49
public function macroForm (MacroNode $ node , PhpWriter $ writer )
50
50
{
51
51
if ($ node ->modifiers ) {
52
- throw new CompileException (" Modifiers are not allowed in { { $ node ->name } } " );
52
+ throw new CompileException (' Modifiers are not allowed in ' . $ node ->getNotation () );
53
53
}
54
54
if ($ node ->prefix ) {
55
55
throw new CompileException ('Did you mean <form n:name=...> ? ' );
56
56
}
57
57
$ name = $ node ->tokenizer ->fetchWord ();
58
58
if ($ name === FALSE ) {
59
- throw new CompileException (" Missing form name in { { $ node ->name } }. " );
59
+ throw new CompileException (' Missing form name in ' . $ node ->getNotation () );
60
60
}
61
61
$ node ->replaced = true ;
62
62
$ node ->tokenizer ->reset ();
63
63
return $ writer ->write (
64
- 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = '
64
+ "/* line $ node ->startLine */ \n"
65
+ . 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = '
65
66
. ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
66
- . '$this->global->uiControl[%node.word], %node.array) '
67
+ . '$this->global->uiControl[%node.word], %node.array); '
67
68
);
68
69
}
69
70
@@ -74,17 +75,17 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
74
75
public function macroFormContainer (MacroNode $ node , PhpWriter $ writer )
75
76
{
76
77
if ($ node ->modifiers ) {
77
- throw new CompileException (" Modifiers are not allowed in { { $ node ->name } } " );
78
+ throw new CompileException (' Modifiers are not allowed in ' . $ node ->getNotation () );
78
79
}
79
80
$ name = $ node ->tokenizer ->fetchWord ();
80
81
if ($ name === FALSE ) {
81
- throw new CompileException (" Missing name in { { $ node ->name } }. " );
82
+ throw new CompileException (' Missing name in ' . $ node ->getNotation () );
82
83
}
83
84
$ node ->tokenizer ->reset ();
84
85
return $ writer ->write (
85
86
'$this->global->formsStack[] = $formContainer = $_form = '
86
87
. ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
87
- . 'end($this->global->formsStack)[%node.word] '
88
+ . 'end($this->global->formsStack)[%node.word]; '
88
89
);
89
90
}
90
91
@@ -95,11 +96,11 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer)
95
96
public function macroLabel (MacroNode $ node , PhpWriter $ writer )
96
97
{
97
98
if ($ node ->modifiers ) {
98
- throw new CompileException (" Modifiers are not allowed in { { $ node ->name } } " );
99
+ throw new CompileException (' Modifiers are not allowed in ' . $ node ->getNotation () );
99
100
}
100
101
$ words = $ node ->tokenizer ->fetchWords ();
101
102
if (!$ words ) {
102
- throw new CompileException (" Missing name in { { $ node ->name } }. " );
103
+ throw new CompileException (' Missing name in ' . $ node ->getNotation () );
103
104
}
104
105
$ node ->replaced = true ;
105
106
$ name = array_shift ($ words );
@@ -131,18 +132,19 @@ public function macroLabelEnd(MacroNode $node, PhpWriter $writer)
131
132
public function macroInput (MacroNode $ node , PhpWriter $ writer )
132
133
{
133
134
if ($ node ->modifiers ) {
134
- throw new CompileException (" Modifiers are not allowed in { { $ node ->name } } " );
135
+ throw new CompileException (' Modifiers are not allowed in ' . $ node ->getNotation () );
135
136
}
136
137
$ words = $ node ->tokenizer ->fetchWords ();
137
138
if (!$ words ) {
138
- throw new CompileException (" Missing name in { { $ node ->name } }. " );
139
+ throw new CompileException (' Missing name in ' . $ node ->getNotation () );
139
140
}
140
141
$ node ->replaced = true ;
141
142
$ name = array_shift ($ words );
142
143
return $ writer ->write (
143
144
($ name [0 ] === '$ ' ? '$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo $_input ' : 'echo end($this->global->formsStack)[%0.word] ' )
144
145
. '->%1.raw '
145
- . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' ),
146
+ . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' )
147
+ . " /* line $ node ->startLine */ " ,
146
148
$ name ,
147
149
$ words ? 'getControlPart( ' . implode (', ' , array_map ([$ writer , 'formatWord ' ], $ words )) . ') ' : 'getControl() '
148
150
);
@@ -156,11 +158,11 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
156
158
{
157
159
$ words = $ node ->tokenizer ->fetchWords ();
158
160
if (!$ words ) {
159
- throw new CompileException (" Missing name in n: { $ node ->name } . " );
161
+ throw new CompileException (' Missing name in ' . $ node ->getNotation () );
160
162
}
161
163
$ name = array_shift ($ words );
162
164
$ tagName = strtolower ($ node ->htmlNode ->name );
163
- $ node ->isEmpty = $ tagName === 'input ' ;
165
+ $ node ->empty = $ tagName === 'input ' ;
164
166
165
167
if ($ tagName === 'form ' ) {
166
168
return $ writer ->write (
@@ -198,13 +200,13 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
198
200
{
199
201
$ tagName = strtolower ($ node ->htmlNode ->name );
200
202
if ($ tagName === 'form ' ) {
201
- $ node ->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), FALSE) ?> ' ;
203
+ $ node ->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), FALSE); ?> ' ;
202
204
} elseif ($ tagName === 'label ' ) {
203
- if ($ node ->htmlNode ->isEmpty ) {
205
+ if ($ node ->htmlNode ->empty ) {
204
206
$ node ->innerContent = "<?php echo \$_input->getLabelPart()->getHtml() ?> " ;
205
207
}
206
208
} elseif ($ tagName === 'button ' ) {
207
- if ($ node ->htmlNode ->isEmpty ) {
209
+ if ($ node ->htmlNode ->empty ) {
208
210
$ node ->innerContent = '<?php echo htmlspecialchars($_input->caption) ?> ' ;
209
211
}
210
212
} else { // select, textarea
@@ -219,16 +221,16 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
219
221
public function macroInputError (MacroNode $ node , PhpWriter $ writer )
220
222
{
221
223
if ($ node ->modifiers ) {
222
- throw new CompileException (" Modifiers are not allowed in { { $ node ->name } } " );
224
+ throw new CompileException (' Modifiers are not allowed in ' . $ node ->getNotation () );
223
225
}
224
226
$ name = $ node ->tokenizer ->fetchWord ();
225
227
$ node ->replaced = true ;
226
228
if (!$ name ) {
227
- return $ writer ->write ('echo %escape($_input->getError()) ' );
229
+ return $ writer ->write ('echo %escape($_input->getError()); ' );
228
230
} elseif ($ name [0 ] === '$ ' ) {
229
- return $ writer ->write ('$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo %escape($_input->getError()) ' , $ name );
231
+ return $ writer ->write ('$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo %escape($_input->getError()); ' , $ name );
230
232
} else {
231
- return $ writer ->write ('echo %escape(end($this->global->formsStack)[%0.word]->getError()) ' , $ name );
233
+ return $ writer ->write ('echo %escape(end($this->global->formsStack)[%0.word]->getError()); ' , $ name );
232
234
}
233
235
}
234
236
0 commit comments