Render grid partials async
This commit is contained in:
@@ -39,38 +39,45 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
private void renderRow(dynamic row)
|
||||
@functions{
|
||||
|
||||
private async Task renderRow(dynamic row)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<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>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control != null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@functions {
|
||||
@functions{
|
||||
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if(cfg != null)
|
||||
if (cfg != null)
|
||||
{
|
||||
foreach (JProperty property in cfg.Properties())
|
||||
{
|
||||
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
|
||||
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
}else {
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections) {
|
||||
@foreach (var sec in Model.sections) {
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@s.grid column">
|
||||
@foreach (var row in s.rows)
|
||||
<div class="col-md-@sec.grid column">
|
||||
@foreach (var row in sec.rows)
|
||||
{
|
||||
renderRow(row, false);
|
||||
}
|
||||
@@ -37,25 +37,29 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
@functions{
|
||||
|
||||
private void renderRow(dynamic row, bool singleColumn)
|
||||
private async Task renderRow(dynamic row, bool singleColumn)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
@if (singleColumn) {
|
||||
@:<div class="container">
|
||||
}
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<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>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control != null && control.editor != null && control.editor.view != null)
|
||||
{
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (singleColumn) {
|
||||
@:</div>
|
||||
@@ -65,23 +69,26 @@
|
||||
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
@functions {
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if(cfg != null)
|
||||
if (cfg != null)
|
||||
{
|
||||
foreach (JProperty property in cfg.Properties())
|
||||
{
|
||||
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
|
||||
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null) {
|
||||
if (style != null)
|
||||
{
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user