Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- var baseColSize = "medium"; //Options: small, medium, large
- }
- @if (Model != null && Model.sections != null)
- {
- foreach (var s in Model.sections)
- {
- foreach (var row in s.rows)
- {
- @renderRow(row, baseColSize);
- }
- }
- }
- @helper renderRow(dynamic row, string colSize)
- {
- <div @RenderElementAttributes(row)>
- <div class="grid-container">
- <div class="two-col-content">
- <div class="grid-x grid-margin-x grid-margin-y">
- @foreach (var area in row.areas)
- {
- <div class="cell @colSize-@area.grid">
- <div @RenderElementAttributes(area)>
- @foreach (var control in area.controls)
- {
- if (control != null && control.editor != null && control.editor.view != null)
- {
- <text>@Html.Partial("grid/editors/base", (object)control)</text>
- }
- }
- </div>
- </div>
- }
- </div>
- </div>
- </div>
- </div>
- }
- @functions {
- public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
- {
- var attrs = new List<string>();
- JObject cfg = contentItem.config;
- if (cfg != null)
- foreach (JProperty property in cfg.Properties())
- {
- attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
- }
- JObject style = contentItem.styles;
- if (style != null)
- {
- var cssVals = new List<string>();
- foreach (JProperty property in style.Properties())
- cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
- if (cssVals.Any())
- attrs.Add("style='" + string.Join(" ", cssVals) + "'");
- }
- return new MvcHtmlString(string.Join(" ", attrs));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement