Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor if condition difference

Why is the second if statement incorrect? note that I attempted to make it a single line.

Correct If Condition

enter image description here

thanks

After Andrei Andrushkevich suggestion, red code. Tree and ul are red/squiggled. Plus the function param is red and all references in the blurred code is red.

enter image description here

like image 600
Valamas Avatar asked Dec 13 '22 11:12

Valamas


1 Answers

The @: sequence indicates that the entire line of content that follows should be treated as a content block.

So @if (condition) { @: Some content } won't work because the last bracket is interpreted as content and another ending } will be expected.

For single line conditions you can use the <text> tag:

@if (condition) { <text>Some content</text> }

like image 113
Paolo Moretti Avatar answered Jan 17 '23 03:01

Paolo Moretti