Razor - How to prevent unwanted line breaks in the view source when using @ {} or @ ()?

When I use @ {} or @ () on a web page and launch it from Visual Studio, in the web browser that I noticed in the view source, this is a line break before the syntax @ {{{{{{{}}} and another line break after the syntax}.

Is there a way to prevent line breaks so that the view source becomes easier to read?

Thanks...

+4
source share
1 answer

I don’t think you can do something regarding line breaks. Formatting is performed in accordance with the source file after compilation and visualization from the server side.

The end-user effect in terms of layout is nothing, since its not a html line break: <br>

You can put the server side code according to the example below, which will stop the line spacing:

 a<br/>@{ /*some code 1 that does not produce a line break*/} b<br /> c<br /> @{ /*some code 2 that does produce line breaks*/ } d<br /> e<br /> 

this will result in the following:

 a<br /> b<br /> c<br /> d<br /> e<br /> 
0
source

Source: https://habr.com/ru/post/1482278/


All Articles