asp.net mvc 3 - MVC 3 Razor Syntax for straight text output? -


How to use a razor / can you type text directly with wrapping it in some type of html tag?

Example (this works but adds extra span tags):

  @ {var foo = true; } @if (foo) {& lt; Span & gt; Yes & lt; / Span & gt; } Other {& lt; Span & gt; No & lt; / Span & gt; }   

I would like to keep my final markup as clear as possible and not want to do additional tags.

Thank you!

Use tags

  @ {Var foo = true; } @if (foo) {& lt; Text & gt; Yes & lt; / Text & gt; } Other {& lt; Text & gt; No & lt; / Text & gt; }   

In the razor view engine to write content in the output & lt; Text & gt; tag signals.

Alternatively, you can @:

  @ {var foo = true; Use; } @if (foo) {@: yes} and {@: no}    

Comments