What you wrote down:
<b>@parameterMapping.Title</b>
(Category: @parameterMapping.Category.Title, Regexp: @parameterMapping.Regexp)
Is actually valid in Razor. My guess is that you have all of this in some conditional or iterative statement (if
or foreach
etc). In this case you can wrap the whole thing in <text>
:
@if(Foo) {
<text><b>@parameterMapping.Title</b>
(Category: @parameterMapping.Category.Title, Regexp: @parameterMapping.Regexp)</text>
}
Instead of <text>
you could use a valid HTML element like <p>
or <div>
. This is because by default after the {
the parser is sitll in "code" mode and needs a markup tag to switch to "markup" mode.
Note that Razor performs tag matching which is why you need to have the whole scope of the if
statement contained in a tag if you want all of it to be treated as markup. Otherwise everything that's not inside of a tag would be treated as code:
@if(Foo) {
// Treate as code
<text>
Markup
<div>More markup</div>
@EscapeIntoCode
</text>
// Treate as code again
}