diff --git a/samples/MvcSample.Web/Views/Home/Create.cshtml b/samples/MvcSample.Web/Views/Home/Create.cshtml
index 6f71264af2..1220da9603 100644
--- a/samples/MvcSample.Web/Views/Home/Create.cshtml
+++ b/samples/MvcSample.Web/Views/Home/Create.cshtml
@@ -1,4 +1,5 @@
@using MvcSample.Web.Models
+@using Microsoft.AspNet.Mvc.ModelBinding
@model User
@{
ViewBag.Title = (Model == null) ? "Create Page" : "Edit Page";
@@ -30,12 +31,17 @@
@foreach (var property in metadata.Properties)
{
- var propertyName = property.PropertyName;
- var propertyTypeName = property.ModelType.Name;
- var propertyDescription = property.Description;
- - Property @propertyName has type @propertyTypeName and description '@propertyDescription'
+ @PropertyListItem(property)
}
}
}
-
\ No newline at end of file
+
+
+@helper PropertyListItem(ModelMetadata property)
+{
+ var propertyName = property.PropertyName;
+ var propertyTypeName = property.ModelType.Name;
+
+ Property @propertyName is type @propertyTypeName and '@(property.Description ?? "no description")'
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs
index b59bc07e1d..fe41055420 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs
@@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.Razor
writeLiteralMethodName: "WriteLiteral",
writeToMethodName: "WriteTo",
writeLiteralToMethodName: "WriteLiteralTo",
- templateTypeName: "Template",
+ templateTypeName: "HelperResult",
defineSectionMethodName: "DefineSection")
{
ResolveUrlMethodName = "Href"
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
index 849bc80181..8629865611 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
@@ -97,10 +97,24 @@ namespace Microsoft.AspNet.Mvc.Razor
{
if (content != null)
{
- var htmlString = content as HtmlString;
- var contentToWrite = htmlString != null ? content.ToString() :
- WebUtility.HtmlEncode(content.ToString());
- writer.Write(contentToWrite);
+ var helperResult = content as HelperResult;
+ if (helperResult != null)
+ {
+ helperResult.WriteTo(writer);
+
+ }
+ else
+ {
+ var htmlString = content as HtmlString;
+ if (htmlString != null)
+ {
+ writer.Write(content.ToString());
+ }
+ else
+ {
+ writer.Write(WebUtility.HtmlEncode(content.ToString()));
+ }
+ }
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Rendering/View/HelperResult.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/HelperResult.cs
new file mode 100644
index 0000000000..74f6b36991
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Rendering/View/HelperResult.cs
@@ -0,0 +1,20 @@
+using System;
+using System.IO;
+
+namespace Microsoft.AspNet.Mvc.Rendering
+{
+ public class HelperResult
+ {
+ private readonly Action _action;
+
+ public HelperResult([NotNull] Action action)
+ {
+ _action = action;
+ }
+
+ public void WriteTo([NotNull] TextWriter writer)
+ {
+ _action(writer);
+ }
+ }
+}