9

我想将原始 html 传递给 @helper 宏...这可能吗?例如:

@helper oneColumn(string content) {
<div class="row">               
  <div class="twelve columns">
    @content                    
  </div>
</div>
}

@put.oneColumn(
  <h1 id="page-heading">HELLO WORLD!</h1>
)
4

3 回答 3

27
@helper oneColumn(Func<dynamic,HelperResult> content) {
<div class="row">               
  <div class="twelve columns">
    @content(null)                    
  </div>
</div>
}

@put.oneColumn( @<h1 id="page-heading">HELLO WORLD!</h1>)
于 2013-12-04T15:43:49.657 回答
1

使用@Html.RawHTML 帮助程序,或将内容设为IHtmlString.

于 2013-06-27T13:34:01.603 回答
0
@helper oneColumn(string content) {
var contentHtml = new HtmlString(content);
<div class="row">               
  <div class="twelve columns">
    @contentHtml                    
  </div>
</div>
}

@put.oneColumn(
  "<h1 id=\"page-heading\">HELLO WORLD!</h1>"
)
于 2014-01-06T18:09:43.067 回答