Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor view engine, how to write inbetween html?

i have some problem with a razor syntax. I would like to know how to write inbetween html.. see this sample..

<ul>
    @foreach (var x in Model) {
        <li>
            @x.Subject - Tags:&nbsp;

            @if (x.Tags != null)
            {

                foreach (var t in x.Tags)
                {
                    @t.Name
                }
            }
            else
            { 
                No tags
            }
        </li>
    }
</ul>

I should be able to write "No Tags" but this doesnt work... No tags seem included in the code (which is not what i want.

Thanks

like image 630
Rushino Avatar asked Feb 10 '11 01:02

Rushino


2 Answers

You need to explicitly tell Razor that you're writing HTML, by writing @:No Tags or <text>No Tags</text>.

like image 166
SLaks Avatar answered Nov 17 '22 17:11

SLaks


Does using the <text> tag work? For example:

<text>No tags</text>
like image 27
dommer Avatar answered Nov 17 '22 17:11

dommer