2011-08-19 56 views
3

我使用的是富文本編輯器來顯示產品頁面上的說明,但頁面呈現爲:如何從富文本編輯器的HTML標籤一把umbraco(剃刀)

<p>text description</p> 

用於描述宏:

剃刀語法:

@foreach (var page in @Model.Children) 
{ 


    <div id="productSection"> 
    <div id="productstext"> 

    <div id="image"> 
    <a href="@page.Url"><img src="@page.productImage" height="200px" width="230px"/></a> </div> 
<div id="title"> 
    <h3>@page.GetProperty("productTitle") </h3> </div> 

<div id="description"> 

@page.GetProperty("product") </div> 
</div> 
</div> 
} 

日Thnx提前

+0

到底是什麼問題?你是說整個'foreach'循環只呈現一個段落,沒有'div',沒有'h3'嗎? – marapet

回答

6

如果問題是如何消除被周圍的富文本呈現的段落標記,您可以嘗試是否下列解決方案適用於您:

@umbraco.library.RemoveFirstParagraphTag(page.product.ToString()) 

您可能想包裝在一個幫手:

@helper RemoveParagraph(HtmlString s) 
{ 
    @Html.Raw(umbraco.library.RemoveFirstParagraphTag(s.ToString())) 
} 

,然後調用ID是這樣的:

@Helpers.RemoveParagraph(page.product) 

要知道,雖然umbraco.library.RemoveFirstParagraphTag也刪除換行符(大部分時間不是問題)。

又見一把umbraco論壇上發帖究竟這個問題:http://our.umbraco.org/forum/developers/razor/19379-Remove-paragraph-tags-with-razor

2

我們遇到了同樣的問題在我們的項目之一,有做這個簡單的方法解決它。用「@ Html.Raw()」包裝該值解決了該問題。

<section class="links"> 
@{ 
    var Link = Model.Content.Descendants("links"); 

    <ul> 
     @foreach (var links in Link) 
     { 
      <li data-category="@(links.GetProperty("weblinkCategory").Value)"> 
       <a href="@(links.GetProperty("weblinkAddress").Value)"> 
        @(links.GetProperty("weblinkTitle").Value) 
        <span>@Html.Raw(links.GetProperty("weblinkDescription").Value)</span> 
       </a> 
      </li> 
    } 
    </ul> 
}