如何在渲染页面CSHTML用剃刀不Servicestack内容页 [英] How to render Razor in cshtml page with Servicestack without content page
问题描述
我在我的模型字符串属性降价,想使其到页面。如果我在同一字符串属性都提供了html我会简单地做:
@ Html.Raw(Model.BodyHtml)
有没有同样的事情,如果字符串包含降价,而不是HTML?即是这样的:
@ Html.MarkdownToHtml(Model.BodyMarkdown)
这个新的 @ Html.RenderMarkdownToHtml()
API刚刚在添加V4 .0.34 + 那现在可在MyGet ,这将让你呈现降价搭配:
@ Html.RenderMarkdownToHtml(Model.BodyMarkdown)
在早期版本的ServiceStack,你会叫降价实现本身来呈现HTML和使用 AsRaw()
扩展方法,所以返回的HTML是不会自动连接codeD,例如:
@(新MarkdownSharp.Markdown()。变换(Model.BodyMarkdown).AsRaw())
I have markdown in string property of my model and would like to render it onto page. If I have html in that same string property I would simply do:
@Html.Raw(Model.BodyHtml)
Is there a same thing if string contains Markdown rather than Html? I.e. something like:
@Html.MarkdownToHtml(Model.BodyMarkdown)
The new @Html.RenderMarkdownToHtml()
API for this has just been added in v4.0.34+ that's now available on MyGet, which will let you render markdown with:
@Html.RenderMarkdownToHtml(Model.BodyMarkdown)
In earlier versions of ServiceStack you would call the Markdown implementation itself to render HTML and use the AsRaw()
extension method so the returned HTML isn't automatically encoded, e.g:
@(new MarkdownSharp.Markdown().Transform(Model.BodyMarkdown).AsRaw())
这篇关于如何在渲染页面CSHTML用剃刀不Servicestack内容页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!