Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequiresCss not working inside a @section block #181

Open
Pustur opened this issue Mar 6, 2023 · 0 comments
Open

RequiresCss not working inside a @section block #181

Pustur opened this issue Mar 6, 2023 · 0 comments

Comments

@Pustur
Copy link

Pustur commented Mar 6, 2023

Hi,

I noticed that sometimes when calling Smidge.RequiresCss inside a partial that is itself called within a @section block, it won't output anything.

Here's a simplified example:

@* /Views/HeroTemplate.cshtml *@

@section hero {
    @await Html.PartialAsync("/Views/Partials/Hero.cshtml")
}
@* /Views/Partials/Hero.cshtml *@

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject Smidge.SmidgeHelper Smidge;
@{
    Smidge.RequiresCss("https://cdn.jsdelivr.net/npm/swiper@8.4.7/swiper-bundle.min.css");
    Smidge.RequiresJs("https://cdn.jsdelivr.net/npm/swiper@8.4.7/swiper-bundle.min.js");
}

@* ...My hero html code... *@

The weird thing is that Smidge.RequiresJs works fine in this scenario.

The problem seems to go away if I call the same partial outside the @section block.

For now the solution I'm using is calling Smidge directly from the HeroTemplate, but that's not ideal.

Any idea what the problem could be? Thanks in advance

EDIT:

Ok the partial has nothing to do with it. I tried to put the Smidge calls directly inside the @section block and the problem is the same. I edited the title to reflect this.

@Pustur Pustur changed the title RequiresCss not working when called inside a partial view that is itself inside a @section block RequiresCss not working inside a @section block Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant