Reputation: 5526
I am trying to use Razor to generate some CSS. However, I am running into problems with conflicting syntax. Eg:
@section css {
<style type="text/css">
#@(Model.InstanceName) {
top: @(Model.Properties["top"])px;
}
</style>
}
What is happening is that the first closing curly brace ( } ) is being interpreted by Razor as the end of the @section, instead of the last one. How can I make Razor ignore it?
Upvotes: 0
Views: 330
Reputation: 5526
I found the problem. It appears this is a bug in ASP.NET MVC4 Beta. That will teach me for using beta software.
It works as expected in ASP.NET MVC 3
Upvotes: 3
Reputation: 887245
Your code works for me.
This would only happen if your HTML tags are imbalanced.
You should either balance your tags or prefix that line with @:
(or wrap in <text>
tags) to prevent it from parsing the }
.
Upvotes: 0