diff --git a/samples/MvcSample.Web/Views/Shared/DisplayTemplates/User.cshtml b/samples/MvcSample.Web/Views/Shared/DisplayTemplates/User.cshtml
index 9d77c13628..5141f4c197 100644
--- a/samples/MvcSample.Web/Views/Shared/DisplayTemplates/User.cshtml
+++ b/samples/MvcSample.Web/Views/Shared/DisplayTemplates/User.cshtml
@@ -1 +1,5 @@
-
This is the DisplayForModel output. Once default templates are implemented this should go away.
\ No newline at end of file
+@using System.Linq
+
+This is the DisplayForModel output. Once default templates are implemented this should go away.
+User Name: @ViewData.Model.Name
+User Model Metadata Property Count: @ViewData.ModelMetadata.Properties.Count()
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs
index 278cf11061..272bdf1c58 100644
--- a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs
@@ -163,33 +163,26 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
public HtmlString Display(string expression,
- string templateName,
- string htmlFieldName,
- object additionalViewData)
+ string templateName,
+ string htmlFieldName,
+ object additionalViewData)
{
var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
return GenerateDisplay(metadata,
- htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),
- templateName,
- additionalViewData);
+ htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),
+ templateName,
+ additionalViewData);
}
- public virtual HtmlString DisplayForModel(string templateName,
- string htmlFieldName,
- object additionalViewData)
+ public HtmlString DisplayForModel(string templateName,
+ string htmlFieldName,
+ object additionalViewData)
{
- var templateBuilder = new TemplateBuilder(ViewContext,
- ViewData,
- ViewData.ModelMetadata,
- htmlFieldName,
- templateName,
- readOnly: true,
- additionalViewData: additionalViewData);
-
- var templateResult = templateBuilder.Build();
-
- return new HtmlString(templateResult);
+ return GenerateDisplay(ViewData.ModelMetadata,
+ htmlFieldName,
+ templateName,
+ additionalViewData);
}
///
diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/TemplatedHelpers/DisplayForModelExtensions.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/TemplatedHelpers/DisplayForModelExtensions.cs
index 776612fe4f..20806158bc 100644
--- a/src/Microsoft.AspNet.Mvc.Rendering/Html/TemplatedHelpers/DisplayForModelExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/TemplatedHelpers/DisplayForModelExtensions.cs
@@ -1,29 +1,35 @@
namespace Microsoft.AspNet.Mvc.Rendering
{
- public static class DisplayForModelExtensions
+ public static class HtmlHelperDisplayForModelExtensions
{
- public static HtmlString DisplayForModel(this IHtmlHelper html)
+ public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html)
{
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: null);
}
- public static HtmlString DisplayForModel(this IHtmlHelper html, object additionalViewData)
+ public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html,
+ object additionalViewData)
{
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: additionalViewData);
}
- public static HtmlString DisplayForModel(this IHtmlHelper html, string templateName)
+ public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html,
+ string templateName)
{
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: null);
}
- public static HtmlString DisplayForModel(this IHtmlHelper html, string templateName, object additionalViewData)
+ public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html,
+ string templateName,
+ object additionalViewData)
{
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData);
}
- public static HtmlString DisplayForModel(this IHtmlHelper html, string templateName, string htmlFieldName)
+ public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html,
+ string templateName,
+ string htmlFieldName)
{
return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null);
}
diff --git a/src/Microsoft.AspNet.Mvc.Rendering/IHtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Rendering/IHtmlHelperOfT.cs
index fd9936af33..4302135189 100644
--- a/src/Microsoft.AspNet.Mvc.Rendering/IHtmlHelperOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Rendering/IHtmlHelperOfT.cs
@@ -69,16 +69,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// The HTML markup for each property in the object that is represented by the expression.
HtmlString DisplayFor(Expression> expression,
- string templateName,
- string htmlFieldName,
- object additionalViewData);
+ string templateName,
+ string htmlFieldName,
+ object additionalViewData);
///
- /// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and additional view data.
+ /// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and additional
+ /// view data.
///
/// The name of the template that is used to render the object.
- /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the same name.
- /// An anonymous object that can contain additional view data that will be merged into the instance that is created for the template.
+ ///
+ /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the
+ /// same name.
+ ///
+ ///
+ /// An anonymous object or dictionary that can contain additional view data that will be merged into the
+ /// instance that is created for the template.
+ ///
/// The HTML markup for each property in the model.
HtmlString DisplayForModel(string templateName, string htmlFieldName, object additionalViewData);