diff --git a/src/Sitecore.AspNetCore.SDK.RenderingEngine/TagHelpers/PlaceholderTagHelper.cs b/src/Sitecore.AspNetCore.SDK.RenderingEngine/TagHelpers/PlaceholderTagHelper.cs index c42ef29..93b876a 100644 --- a/src/Sitecore.AspNetCore.SDK.RenderingEngine/TagHelpers/PlaceholderTagHelper.cs +++ b/src/Sitecore.AspNetCore.SDK.RenderingEngine/TagHelpers/PlaceholderTagHelper.cs @@ -100,7 +100,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu if (!foundPlaceholderFeatures) { - output.Content.SetHtmlContent($""); + output.Content.SetHtmlContent($"
"); } } @@ -109,14 +109,12 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu Placeholder? placeholderFeatures = null; // try to get the placeholder from the "context" component - renderingContext.Component?.Placeholders.TryGetValue(placeholderName, out placeholderFeatures); - - // top level placeholders do not have a "context" component set, so their component list can be retrieved directly from the Sitecore Route object - if (placeholderFeatures?.Count > 0) + if (renderingContext.Component?.Placeholders.TryGetValue(placeholderName, out placeholderFeatures) ?? false) { return placeholderFeatures; } + // top level placeholders do not have a "context" component set, so their component list can be retrieved directly from the Sitecore Route object Route? route = renderingContext.Response?.Content?.Sitecore?.Route; route?.Placeholders.TryGetValue(placeholderName, out placeholderFeatures); diff --git a/tests/Sitecore.AspNetCore.SDK.RenderingEngine.Tests/TagHelpers/PlaceholderTagHelperFixture.cs b/tests/Sitecore.AspNetCore.SDK.RenderingEngine.Tests/TagHelpers/PlaceholderTagHelperFixture.cs index ce58090..99ab560 100644 --- a/tests/Sitecore.AspNetCore.SDK.RenderingEngine.Tests/TagHelpers/PlaceholderTagHelperFixture.cs +++ b/tests/Sitecore.AspNetCore.SDK.RenderingEngine.Tests/TagHelpers/PlaceholderTagHelperFixture.cs @@ -236,7 +236,7 @@ public async Task ProcessAsync_PlaceholderNameInLayoutServiceResponseAndPlacehol await sut.ProcessAsync(tagHelperContext, tagHelperOutput); // Assert - tagHelperOutput.Content.GetContent().Should().Be($""); + tagHelperOutput.Content.GetContent().Should().Be($"
"); } [Theory]