Files
Umbraco-CMS/src/Umbraco.Web.Common/Extensions/RazorPageExtensions.cs
Nikolaj Geisle c576bbea03 v10: Fix build warnings in Web.Common (#12349)
* Run code cleanup

* Run dotnet format

* Start manual cleanup in Web.Common

* Finish up manual cleanup

* Fix tests

* Fix up InMemoryModelFactory.cs

* Inject proper macroRenderer

* Update src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update src/Umbraco.Web.Common/Filters/ValidateUmbracoFormRouteStringAttribute.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Fix based on review

Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
2022-05-09 09:39:46 +02:00

23 lines
878 B
C#

using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Razor;
namespace Umbraco.Extensions;
/// <summary>
/// Extension methods for <see cref="RazorPage" />
/// </summary>
public static class RazorPageExtensions
{
/// <summary>
/// Renders a section with default content if the section isn't defined
/// </summary>
public static HtmlString? RenderSection(this RazorPage webPage, string name, HtmlString defaultContents)
=> webPage.IsSectionDefined(name) ? webPage.RenderSection(name) : defaultContents;
/// <summary>
/// Renders a section with default content if the section isn't defined
/// </summary>
public static HtmlString? RenderSection(this RazorPage webPage, string name, string defaultContents)
=> webPage.IsSectionDefined(name) ? webPage.RenderSection(name) : new HtmlString(defaultContents);
}