Rename PartialTagHelper `asp-for` to `for`.

#7379
This commit is contained in:
N. Taylor Mullen 2018-03-15 11:25:10 -07:00
parent 90b07a9e9a
commit 4e7d1a5a32
3 changed files with 4 additions and 6 deletions

View File

@ -20,7 +20,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
[HtmlTargetElement("partial", Attributes = "name", TagStructure = TagStructure.WithoutEndTag)]
public class PartialTagHelper : TagHelper
{
private const string ForAttributeName = "asp-for";
private readonly ICompositeViewEngine _viewEngine;
private readonly IViewBufferScope _viewBufferScope;
@ -40,7 +39,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
/// <summary>
/// An expression to be evaluated against the current model.
/// </summary>
[HtmlAttributeName(ForAttributeName)]
public ModelExpression For { get; set; }
/// <summary>
@ -102,7 +100,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
// Determine which ViewData we should use to construct a new ViewData
var baseViewData = ViewData ?? ViewContext.ViewData;
// Use the rendering View's model only if an asp-for expression does not exist
// Use the rendering View's model only if an for expression does not exist
var model = For != null ? For.Model : ViewContext.ViewData.Model;
var newViewData = new ViewDataDictionary<object>(baseViewData, model);
var partialViewContext = new ViewContext(ViewContext, view, newViewData, writer);

View File

@ -1,4 +1,4 @@
@using HtmlGenerationWebSite.Models
@using HtmlGenerationWebSite.Models
@model IList<Product>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@ -15,7 +15,7 @@
<label asp-for="@Model[i].HomePage" class="product"></label>
<input asp-for="@Model[i].HomePage" type="url" size="50" disabled="disabled" readonly="readonly" />
</div>
<partial name="_ProductPartial" asp-for="@Model[i]" />
<partial name="_ProductPartial" for="@Model[i]" />
}
@* Print the HtmlFieldPrefix outside of the partial tag helper to ensure it hasn't been modified *@
<div>HtmlFieldPrefix = @ViewData.TemplateInfo.HtmlFieldPrefix</div>

View File

@ -2,4 +2,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<h3>@Html.DisplayFor(m => m.City)</h3>
<partial name="_EmployeePartial" asp-for="Employee" />
<partial name="_EmployeePartial" for="Employee" />