Support @helper ExtensionMethod(this HtmlHelper html) for views in APP_CODE
Support creating extension methods with the @helper razor syntax, inside the APP_CODE folder.
This could be very useful, when creating html helpers, like the following code:
@helper ExtensionMethod(this HtmlHelper html, string data, string action)
{
<text>
<div>@data</div>
should I want to use Html here it is fine:
@html.ActionLink("Link text", action)
should I want to use Url here...
@{var url = new UrlHelper(html.ViewContext.RequestContext)}
@url.Action(action)
</text>
}
And be called inside any other view like this:
@Html.ExtensionMethod("Some text", "MyAction")
That'd be awesome! An easy way to make Html helpers!!!
1 comment
-
Miguel Angelo Santos Bicudo
commented
Suggestion on how to solve: invent a @static razor keyword, that cannot be used with @inherits... and that would tell that there is no base class, and that the class is static.