Remove the @helper directive from Razor #281

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

Projects

None yet

6 participants

@pranavkm
Member

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 ajaybhargavb added 2 - Working and removed 1 - Ready labels Mar 17, 2015
@ajaybhargavb ajaybhargavb added a commit to aspnet/Mvc that referenced this issue Mar 17, 2015
@ajaybhargavb ajaybhargavb React to aspnet/Razor#281 changes a328809
@ajaybhargavb ajaybhargavb added a commit to aspnet/Mvc that referenced this issue Mar 17, 2015
@ajaybhargavb ajaybhargavb React to aspnet/Razor#281 changes 1c00cfe
@ajaybhargavb
Member

b3c6097

@ajaybhargavb ajaybhargavb added 3 - Done and removed 2 - Working labels Mar 17, 2015
@ajaybhargavb ajaybhargavb added a commit to aspnet/MusicStore that referenced this issue Mar 17, 2015
@ajaybhargavb ajaybhargavb React to aspnet/Razor#281 changes 6771be8
@ajaybhargavb ajaybhargavb added a commit to aspnet/MusicStore that referenced this issue Mar 17, 2015
@ajaybhargavb ajaybhargavb React to aspnet/Razor#281 changes 68a125b
@ktos ktos added a commit to ktos/MarkdownCms that referenced this issue Aug 20, 2015
@ktos ktos moving DirectoryTree helper into partial view
@helper syntax was removed in ASP.NET 5 beta 4, see also:
aspnet/Razor#281
f10d923
@alexaku
alexaku commented Mar 15, 2016

@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

Implementation of the ViewComponents turned out horrible.

@alexaku
alexaku commented Mar 16, 2016

@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 join this conversation on GitHub. Already have an account? Sign in to comment