Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Razor + Passing Raw HTML into @helper macro

Tags:

.net

razor

I want to pass raw html into a @helper macro... is this possible? For instance:

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

@put.oneColumn(
  <h1 id="page-heading">HELLO WORLD!</h1>
)
like image 369
worked Avatar asked Jun 27 '13 13:06

worked


2 Answers

@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>)
like image 173
Maslow Avatar answered Oct 31 '22 22:10

Maslow


Use the @Html.Raw HTML helper, or make content an IHtmlString.

like image 34
Daniel A. White Avatar answered Oct 31 '22 21:10

Daniel A. White