在一个循环中,我需要在第一个之后将div
包装成隐藏它们的机制,并在展开时显示,这很容易。
//above this lives code that draws a product section
if (product.DisplayOrder == 1 && Model.Count > 1)
{
<div class="arrow-with-text" style="cursor: pointer;">
<div class="arrow-right"></div>
<div class="arrow-down" style="display: none"></div>
<div style="margin-left: 2em;margin-top: -1.3em;font-size: 1.2em;color: #2280c4;">Other available Wills…</div>
</div>
<div class="other-wills" style="display: none">
}
else (product.DisplayOrder == Model.Count)
{
</div>
}
我所期望的是首先被包裹在other-wills
div中然后在最后一个被关闭的所有部分。实际得到的是这个。
<div class="arrow-with-text" style="cursor: pointer;">
<div class="arrow-right"></div>
<div class="arrow-down" style="display: none"></div>
<div style="margin-left: 2em;margin-top: -1.3em;font-size: 1.2em;color: #2280c4;">Other available Wills…</div>
</div>
<div class="other-wills" style="display: none">
}
else (product.DisplayOrder == Model.Count)
{
</div>
<div class="sections-wrapper">
这与我的预期完全不同(它将}else product.DisplayOrder == Model.Count){
作为文本重新发送。)
如何让剃刀正确解释if
语句和else
的正确结束?
答案 0 :(得分:1)
使用
@Html.Raw("</div>")
和
@Html.Raw("<div class=\"your-class\">")
用于'stray'动态divs