Skip to content

Commit

Permalink
Try fixing it for real.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jul 27, 2024
1 parent 7de5784 commit b341fc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using Microsoft.AspNetCore.Html;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Html;
Expand All @@ -19,13 +21,13 @@ public class HtmlShape : IHtmlContent, IPositioned, IShape

private readonly IHtmlContent _value;

public string Position { get; set; }
public string? Position { get; set; }

public ShapeMetadata Metadata { get; set; } = new();

public string Id { get; set; }
public string? Id { get; set; }

public string TagName { get; set; }
public string? TagName { get; set; }

public IList<string> Classes => [];

Expand All @@ -35,14 +37,14 @@ public class HtmlShape : IHtmlContent, IPositioned, IShape

public IReadOnlyList<IPositioned> Items => [];

public HtmlShape(IHtmlContent value, string position)
public HtmlShape(IHtmlContent? value, string? position = null)
{
_value = value;
_value = value ?? new HtmlString(string.Empty);
Position = position;
}

public HtmlShape(string value, string position)
: this(new HtmlContentString(value), position)
public HtmlShape(string? value, string? position = null)
: this(new HtmlContentString(value ?? string.Empty), position)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public record ScriptModuleResourceFilter(ILayoutAccessor LayoutAccessor) : IAsyn
{
public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
var html = DisplayScriptModuleResources(context.HttpContext.RequestServices);
var shape = new HtmlShape(html, "before");
if (DisplayScriptModuleResources(context.HttpContext.RequestServices) is { } html)
{
await LayoutAccessor.AddShapeToZoneAsync(CommonLocationNames.Content, new HtmlShape(html), "After");
}

await LayoutAccessor.AddShapeToZoneAsync("Content", shape, "After");
await next();
}

Expand Down

0 comments on commit b341fc1

Please sign in to comment.