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

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -