OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.37k stars 2.38k forks source link

style at Head not work in Shape #13887

Open devenliu opened 1 year ago

devenliu commented 1 year ago

Describe the bug

<style at="Head"> block defined in Shape is not rendered

To Reproduce

Steps to reproduce the behavior:

  1. Create a MyShape.cshtml
  2. Define <style at="Head">
  3. Run

MyShape.cshtml

<div class="myshape">MyShape Html</div>

<style at="Head">
    .myshape {
        color: red;
        font-size: 18px;
    }
</style>

Layout.cshtml

<!DOCTYPE html>
<html lang="@Orchard.CultureName()">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@RenderTitleSegments(Site.SiteName, "before")</title>
    <link type="image/x-icon" rel="shortcut icon" href="~/TheTheme/favicon.ico">
    <script asp-name="bootstrap" version="5" at="Foot"></script>
    <style asp-name="thetheme-bootstrap-oc" version="1"></style>
    <style asp-name="font-awesome" version="6"></style>
    <resources type="Meta" />
    <resources type="HeadLink" />
    <resources type="Stylesheet" />
    <resources type="HeadScript" />
    @await RenderSectionAsync("HeadMeta", required: false)
</head>
<body dir="@Orchard.CultureDir()">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container">
            <shape type="Branding" />
            <button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbar" aria-expanded="false" aria-controls="navbar" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbar">
                <menu alias="alias:main-menu" cache-id="main-menu" cache-fixed-duration="00:05:00" cache-tag="alias:main-menu" />
                <shape type="LoginMenu" />
            </div>
        </div>
    </nav>
    @await RenderSectionAsync("Header", required: false)
    <main class="container">
        @await RenderSectionAsync("Messages", required: false)
        @await RenderBodyAsync()
    </main>
    @if (IsSectionDefined("Footer"))
    {
        <footer>
            <div class="container">
                @await RenderSectionAsync("Footer", required: false)
            </div>
        </footer>
    }

    <!-- This -->
    <shape Type="MyShape" />

    <resources type="FootScript" />
</body>
</html>

Expected behavior

The