diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
index 7606b6a..ee47164 100644
--- a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
+++ b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
@@ -12,6 +12,56 @@ namespace Archetype.Extensions
///
public static class HtmlHelperExtensions
{
+ ///
+ /// Renders a single archtype partial from a fieldset
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel)
+ {
+ return RenderPartial(htmlHelper, fieldsetModel, null, null);
+ }
+
+ ///
+ /// Renders the fieldset partial
+ ///
+ /// The HTML helper.
+ ///
+ /// The partial path.
+ /// The view data dictionary.
+ ///
+ private static IHtmlString RenderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
+ {
+ var context = HttpContext.Current;
+
+ if (fieldsetModel == null || context == null)
+ {
+ return new HtmlString("");
+ }
+
+ var sb = new StringBuilder();
+
+ var pathToPartials = "~/Views/Partials/Archetype/";
+ if (!string.IsNullOrEmpty(partialPath))
+ {
+ pathToPartials = partialPath;
+ }
+
+ var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";
+
+ if (System.IO.File.Exists(context.Server.MapPath(partial)))
+ {
+ sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
+ }
+ else
+ {
+ LogHelper.Info(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
+ }
+
+ return new HtmlString(sb.ToString());
+ }
+
///
/// Renders the archetype partials.
///
@@ -72,31 +122,11 @@ namespace Archetype.Extensions
{
var context = HttpContext.Current;
- if (archetypeModel == null || context == null)
- {
- return new HtmlString("");
- }
-
var sb = new StringBuilder();
- var pathToPartials = "~/Views/Partials/Archetype/";
- if (!string.IsNullOrEmpty(partialPath))
- {
- pathToPartials = partialPath;
- }
-
foreach (var fieldsetModel in archetypeModel)
{
- var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";
-
- if (System.IO.File.Exists(context.Server.MapPath(partial)))
- {
- sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
- }
- else
- {
- LogHelper.Info(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
- }
+ sb.AppendLine(RenderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString());
}
return new HtmlString(sb.ToString());