剃刀`if`不注册收盘`}`如果有打开`&LT;表&gt;'的标签? [英] Razor `if` does not register closing `}` if there is an opened `<table>` tag?
本文介绍了剃刀`if`不注册收盘`}`如果有打开`&LT;表&gt;'的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这code,在剃刀视图:
This code, in a Razor view:
if (true)
{
<table>
<tbody>
}
...
if (true)
{
</tbody>
</table>
}
不运行。它声称,没有结束}
上的第一个如果()
语句,我猜这是因为在&LT;表&gt;
标签
does not run. It claims that there is no closing }
on the first if()
statement, and I'm guessing it's because of the <table>
tag.
有没有办法可以解决这个有条件地插入我的&LT;表&gt;
标签
Is there a way I can work around this to conditionally insert my <table>
tags?
推荐答案
尝试prepending与标记@:
:
Try prepending the tags with @:
:
if (true)
{
@:<table>
@:<tbody>
}
...
if (true)
{
@:</tbody>
@:</table>
}
这篇关于剃刀`if`不注册收盘`}`如果有打开`&LT;表&gt;'的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文