@@ -63,10 +63,10 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
6363 $ node ->replaced = true ;
6464 $ node ->tokenizer ->reset ();
6565 return $ writer ->write (
66- "/* line $ node ->startLine */ \n"
67- . 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = '
66+ 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = '
6867 . ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
69- . '$this->global->uiControl[%node.word], %node.array); '
68+ . '$this->global->uiControl[%node.word], %node.array) '
69+ . " /* line $ node ->startLine */; "
7070 );
7171 }
7272
@@ -90,7 +90,8 @@ public function macroFormContext(MacroNode $node, PhpWriter $writer)
9090 return $ writer ->write (
9191 '$form = $this->global->formsStack[] = '
9292 . ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
93- . '$this->global->uiControl[%node.word]; '
93+ . '$this->global->uiControl[%node.word] '
94+ . " /* line $ node ->startLine */; "
9495 );
9596 }
9697
@@ -110,8 +111,9 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer)
110111 $ node ->tokenizer ->reset ();
111112 return $ writer ->write (
112113 '$this->global->formsStack[] = $formContainer = '
113- . ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
114- . 'end($this->global->formsStack)[%node.word]; '
114+ . ($ name [0 ] === '$ ' ? 'is_object(%node.word) ? %node.word : ' : '' )
115+ . 'end($this->global->formsStack)[%node.word] '
116+ . " /* line $ node ->startLine */; "
115117 );
116118 }
117119
@@ -131,9 +133,12 @@ public function macroLabel(MacroNode $node, PhpWriter $writer)
131133 $ node ->replaced = true ;
132134 $ name = array_shift ($ words );
133135 return $ writer ->write (
134- ($ name [0 ] === '$ ' ? '$ʟ_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; if ($ʟ_label = $ʟ_input ' : 'if ($ʟ_label = end($this->global->formsStack)[%0.word] ' )
135- . '->%1.raw) echo $ʟ_label '
136- . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' ),
136+ ($ name [0 ] === '$ '
137+ ? '$ʟ_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; if ($ʟ_label = $ʟ_input '
138+ : 'if ($ʟ_label = end($this->global->formsStack)[%0.word] '
139+ )
140+ . '->%1.raw) echo $ʟ_label '
141+ . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' ),
137142 $ name ,
138143 $ words ? ('getLabelPart( ' . implode (', ' , array_map ([$ writer , 'formatWord ' ], $ words )) . ') ' ) : 'getLabel() '
139144 );
@@ -168,9 +173,9 @@ public function macroInput(MacroNode $node, PhpWriter $writer)
168173 $ name = array_shift ($ words );
169174 return $ writer ->write (
170175 ($ name [0 ] === '$ ' ? '$ʟ_input = $_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo $ʟ_input ' : 'echo end($this->global->formsStack)[%0.word] ' )
171- . '->%1.raw '
172- . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' )
173- . " /* line $ node ->startLine */ " ,
176+ . '->%1.raw '
177+ . ($ node ->tokenizer ->isNext () ? '->addAttributes(%node.array) ' : '' )
178+ . " /* line $ node ->startLine */; " ,
174179 $ name ,
175180 $ words ? 'getControlPart( ' . implode (', ' , array_map ([$ writer , 'formatWord ' ], $ words )) . ') ' : 'getControl() '
176181 );
@@ -199,7 +204,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
199204 $ node ->openingCode = $ writer ->write (
200205 '<?php $form = $this->global->formsStack[] = '
201206 . ($ name [0 ] === '$ ' ? 'is_object(%0.word) ? %0.word : ' : '' )
202- . ' $this->global->uiControl[%0.word]; ?> ' ,
207+ . "\ $this->global->uiControl[%0.word] /* line $ node -> startLine */ ; ?>" ,
203208 $ name
204209 );
205210 return $ writer ->write (
@@ -210,8 +215,9 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
210215 $ method = $ tagName === 'label ' ? 'getLabel ' : 'getControl ' ;
211216 return $ writer ->write (
212217 '$ʟ_input = $_input = ' . ($ name [0 ] === '$ ' ? 'is_object(%0.word) ? %0.word : ' : '' )
213- . 'end($this->global->formsStack)[%0.word]; echo $ʟ_input->%1.raw '
214- . ($ definedHtmlAttributes ? '->addAttributes(%2.var) ' : '' ) . '->attributes() ' ,
218+ . 'end($this->global->formsStack)[%0.word]; echo $ʟ_input->%1.raw '
219+ . ($ definedHtmlAttributes ? '->addAttributes(%2.var) ' : '' ) . '->attributes() '
220+ . " /* line $ node ->startLine */; " ,
215221 $ name ,
216222 $ method . 'Part( ' . implode (', ' , array_map ([$ writer , 'formatWord ' ], $ words )) . ') ' ,
217223 array_fill_keys ($ definedHtmlAttributes , null )
@@ -234,17 +240,18 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
234240 {
235241 $ tagName = strtolower ($ node ->htmlNode ->name );
236242 if ($ tagName === 'form ' ) {
237- $ node ->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?> ' ;
243+ $ node ->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) '
244+ . " /* line $ node ->startLine */; ?> " ;
238245 } elseif ($ tagName === 'label ' ) {
239246 if ($ node ->htmlNode ->empty ) {
240- $ node ->innerContent = ' <?php echo $ʟ_input->getLabelPart()->getHtml() ?> ' ;
247+ $ node ->innerContent = " <?php echo \ $ʟ_input->getLabelPart()->getHtml() /* line $ node -> startLine */; ?> " ;
241248 }
242249 } elseif ($ tagName === 'button ' ) {
243250 if ($ node ->htmlNode ->empty ) {
244- $ node ->innerContent = ' <?php echo htmlspecialchars($ʟ_input->getCaption()) ?> ' ;
251+ $ node ->innerContent = " <?php echo htmlspecialchars( \ $ʟ_input->getCaption()) /* line $ node -> startLine */; ?> " ;
245252 }
246253 } else { // select, textarea
247- $ node ->innerContent = ' <?php echo $ʟ_input->getControl()->getHtml() ?> ' ;
254+ $ node ->innerContent = " <?php echo \ $ʟ_input->getControl()->getHtml() /* line $ node -> startLine */; ?> " ;
248255 }
249256 }
250257
@@ -260,11 +267,15 @@ public function macroInputError(MacroNode $node, PhpWriter $writer)
260267 $ name = $ node ->tokenizer ->fetchWord ();
261268 $ node ->replaced = true ;
262269 if (!$ name ) {
263- return $ writer ->write (' echo %escape($ʟ_input->getError()); ' );
270+ return $ writer ->write (" echo %escape( \ $ʟ_input->getError()) /* line $ node -> startLine */; " );
264271 } elseif ($ name [0 ] === '$ ' ) {
265- return $ writer ->write ('$ʟ_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo %escape($ʟ_input->getError()); ' , $ name );
272+ return $ writer ->write (
273+ '$ʟ_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; '
274+ . "echo %escape( \$ʟ_input->getError()) /* line $ node ->startLine */; " ,
275+ $ name
276+ );
266277 } else {
267- return $ writer ->write (' echo %escape(end($this->global->formsStack)[%0.word]->getError()); ' , $ name );
278+ return $ writer ->write (" echo %escape(end( \ $this->global->formsStack)[%0.word]->getError()) /* line $ node -> startLine */; " , $ name );
268279 }
269280 }
270281
0 commit comments