Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Remove the @helper directive from Razor #281

Closed
pranavkm opened this issue Jan 28, 2015 · 4 comments
Closed

Remove the @helper directive from Razor #281

pranavkm opened this issue Jan 28, 2015 · 4 comments

Comments

@pranavkm
Copy link
Contributor

At this point, the design for the @helper directive seems incomplete vis-a-vis

  1. support for async code
  2. support for Helper files that could be placed under App_Code

Based on design discussion for aspnet/Mvc#1130, the current thought is to remove the @helper feature until we come up with a better design for these questions.

@yishaigalatzer yishaigalatzer added this to the 4.0.0-rc1 milestone Jan 29, 2015
@danroth27 danroth27 modified the milestone: 4.0.0-rc1 Mar 16, 2015
@danroth27 danroth27 added this to the 4.0.0-rc1 milestone Mar 16, 2015
ajaybhargavb added a commit to aspnet/Mvc that referenced this issue Mar 17, 2015
ajaybhargavb added a commit to aspnet/Mvc that referenced this issue Mar 17, 2015
@ajaybhargavb
Copy link
Contributor

b3c6097

ajaybhargavb added a commit to aspnet/MusicStore that referenced this issue Mar 17, 2015
ajaybhargavb added a commit to aspnet/MusicStore that referenced this issue Mar 17, 2015
ktos added a commit to ktos/MarkdownCms that referenced this issue Aug 20, 2015
@Helper syntax was removed in ASP.NET 5 beta 4, see also:
aspnet/Razor#281
@alexaku-zz
Copy link

@Helper is a simple construction that intended for frequent use in place. @Helper is not intended for an async code embedding or a detached code use. It is useful when we need to define tiny portion of the parameterized html-code inside the View-file and reuse it inside the same View-file. The most meaningful thing is direct access to a Model from @Helper. In other words, helper is a simple context-related part that completely depended on a concrete View-file. Delete of this functionality is a hooliganism.

@ateregulov
Copy link

Implementation of the ViewComponents turned out horrible.

@alexaku-zz
Copy link

@pranavkm, @ajaybhargavb, @yishaigalatzer
You have provided us with TagHelpers that are going to be added to ASP.NET MVC 6 (RTM), basically to replace @helpers. Each tag helper is a new separate file (class). Furthermore, each of these separate file can't contain an HTML markup (Razor). There are only C# or VB code. If you remember ViewComponents, there will be appear even two files. How can I reuse some portion of the simple HTML code in my View without adding a bunch of extra files? If you retain the @functions in the Razor despite deletion of the @Helper, than you must add HTML markup feature in their bodies. See below two @functions that could perform the same code.

@functions {

public HtmlString GetTableHeader1(String className)
{
HtmlString result = <text>
<tr class="@className">
<td title="abc">one</td>
<td title="xyz">two</td>
</tr>
</text>;
return result;
}

public HtmlString GetTableHeader2(String className)
{
HtmlString result = new HtmlString(@"
<tr class=""" + Html.Encode(className) + @""">
<td title=""abc"">one</td>
<td title=""xyz"">two</td>
</tr>
");
return result;
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants