如何从 Umbraco (Razor) 的富文本编辑器中删除 html 标签
我正在使用富文本编辑器在产品页面上显示描述,但页面呈现为:
<p>text description</p>
用于描述的宏是:
Razor 语法:
@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
I am using a rich text editor to display description on the products page , but the page renders as :
<p>text description</p>
The macro for description is :
Razor syntax:
@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 in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果问题是如何删除在富文本周围呈现的段落标签,您可以尝试以下解决方案是否适合您:
您可能希望将其包装在助手中:
然后像这样调用 id:
但请注意
umbraco.library.RemoveFirstParagraphTag
还可以删除换行符(大多数时候这不是问题)。另请参阅有关此问题的 Umbraco 论坛帖子: http://our.umbraco.org/forum/developers/razor/19379-Remove-paragraph-tags-with-razor
If the question is how to remove the paragraph tag which is rendered around the rich text, you may try the whether the following solution works for you:
You may want to wrap that in a helper:
and then call id like this:
Be aware though that
umbraco.library.RemoveFirstParagraphTag
also removes line breaks (which most of the time is not a problem).See also the Umbraco forum post about exactly this question: http://our.umbraco.org/forum/developers/razor/19379-Remove-paragraph-tags-with-razor
我们在一个项目中遇到了同样的问题,并用这种简单的方法解决了它。用“@Html.Raw()”包装该值解决了该问题。
We ran into this same problem on one of our projects and solved it with this simple way of doing it. Wrapping the value with an "@Html.Raw()" fixed the issue.
Umbraco 8 删除了已弃用的方法
RemoveFirstParagraphTag
。相反,您可以使用:
其中
Content
是您的属性的名称。Umbraco 8 has removed the deprecated method
RemoveFirstParagraphTag
.Instead you can use:
Where
Content
is the name of your Property.