diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
index ee47164..204fb80 100644
--- a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
+++ b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
@@ -13,14 +13,23 @@ namespace Archetype.Extensions
public static class HtmlHelperExtensions
{
///
- /// Renders a single archtype partial from a fieldset
+ /// Renders the partials based on the model, partial path and given viewdata dictionary.
///
/// The HTML helper.
- /// The fieldset model.
+ /// The archetype model.
+ /// The partial path.
+ /// The view data dictionary.
///
- public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel)
+ private static IHtmlString _renderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
{
- return RenderPartial(htmlHelper, fieldsetModel, null, null);
+ var sb = new StringBuilder();
+
+ foreach (var fieldsetModel in archetypeModel)
+ {
+ sb.AppendLine(_renderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString());
+ }
+
+ return new HtmlString(sb.ToString());
}
///
@@ -31,7 +40,7 @@ namespace Archetype.Extensions
/// The partial path.
/// The view data dictionary.
///
- private static IHtmlString RenderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
+ private static IHtmlString _renderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
{
var context = HttpContext.Current;
@@ -42,13 +51,15 @@ namespace Archetype.Extensions
var sb = new StringBuilder();
+ //default
var pathToPartials = "~/Views/Partials/Archetype/";
+
if (!string.IsNullOrEmpty(partialPath))
{
pathToPartials = partialPath;
}
- var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";
+ var partial = string.Format("{0}{1}.cshtml", pathToPartials, fieldsetModel.Alias);
if (System.IO.File.Exists(context.Server.MapPath(partial)))
{
@@ -62,6 +73,42 @@ namespace Archetype.Extensions
return new HtmlString(sb.ToString());
}
+ ///
+ /// 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 archetype partial.
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ /// The partial view.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView)
+ {
+ return _renderPartial(htmlHelper, fieldsetModel, partialView, null);
+ }
+
+ ///
+ /// Renders the archetype partial.
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ /// The partial view.
+ /// The view data dictionary.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView, ViewDataDictionary viewDataDictionary)
+ {
+ return _renderPartial(htmlHelper, fieldsetModel, partialView, viewDataDictionary);
+ }
+
///
/// Renders the archetype partials.
///
@@ -70,7 +117,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel)
{
- return RenderPartials(htmlHelper, archetypeModel, null, null);
+ return _renderPartials(htmlHelper, archetypeModel, null, null);
}
///
@@ -82,7 +129,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath)
{
- return RenderPartials(htmlHelper, archetypeModel, partialPath, null);
+ return _renderPartials(htmlHelper, archetypeModel, partialPath, null);
}
///
@@ -94,7 +141,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary)
{
- return RenderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
+ return _renderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
}
///
@@ -107,29 +154,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
{
- return htmlHelper.RenderPartials(archetypeModel, partialPath, viewDataDictionary);
- }
-
- ///
- /// Renders the partials based on the model, partial path and given viewdata dictionary.
- ///
- /// The HTML helper.
- /// The archetype model.
- /// The partial path.
- /// The view data dictionary.
- ///
- private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
- {
- var context = HttpContext.Current;
-
- var sb = new StringBuilder();
-
- foreach (var fieldsetModel in archetypeModel)
- {
- sb.AppendLine(RenderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString());
- }
-
- return new HtmlString(sb.ToString());
+ return htmlHelper._renderPartials(archetypeModel, partialPath, viewDataDictionary);
}
}
}
\ No newline at end of file