Skip to content

Instantly share code, notes, and snippets.

@Buildstarted
Created January 6, 2012 04:01
Show Gist options
  • Save Buildstarted/1568896 to your computer and use it in GitHub Desktop.
Save Buildstarted/1568896 to your computer and use it in GitHub Desktop.
<pre>@if(someBool){<text>output</text>}</pre>
<pre>@if(someBool){
<text>output</text>
}</pre>
The above items create different output.
Specifically whitespace between { } is maintained when it shouldn't be on the second one.
The expected output for both statements should simply be "<pre>output</pre>".
@Buildstarted
Copy link
Author

Absolutely it should ignore it. For instance: click here

That will result in a url that looks like: "/somepath? somevalue=whatever" - which is invalid and unacceptable. In addition to <pre></pre> being invalid as it will have tabs or spaces and line feeds is the second example is used.

@Antaris
Copy link

Antaris commented Jan 6, 2012

Perhaps, worth asking Andrew Nurse about it?

@Buildstarted
Copy link
Author

Yeah. Already did and he said it was by design to preserve whitespace for stuff like lists. The only way to get around it is to remove all whitespace which can result in ugly, hard to read html/code blocks :)

@Antaris
Copy link

Antaris commented Jan 6, 2012

Lol, alternatively @(someBool ? "output" : "")

@Buildstarted
Copy link
Author

That's an alternative to the specific example of a boolean check but it affects any block level code such as for,foreach and so forth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment