cofoundry-cms / cofoundry

Cofoundry is an extensible and flexible .NET Core CMS & application framework focusing on code first development
https://www.cofoundry.org
MIT License
836 stars 146 forks source link

Modular CSS and JavaScript includes #412

Closed JornWildt closed 3 years ago

JornWildt commented 3 years ago

It would be neat to have a standard way of saying "Include script/stylesheet XXX" in a razor view component. It is not possible to do using standard razor sections in partial views and view components, so something along the lines of an HTML helper is needed:

@Html.AddScript("~/js/script.js")
@Html.AddStylesheet("~/css/style.css")

and then have similar sections in the _Layout.cshtml file:

<head>
  @Html.IncludeStylesheetsHere()
</head>
<body>
  @Html.IncludeScriptsHere()
</body>

But maybe it is better to use a JS framework for it instead? For instance "Require JS"?

HeyJoel commented 3 years ago

This doesn't seem particularly relevant for Cofoundry. I know we have a few HTML helpers, but generally we try to leave MVC / FrontEnd up to you.If it's a feature missing from Razor then perhaps there's another package out there that can handle it?

JornWildt commented 3 years ago

That's fine. It is not specific for Cofoundry - though a natural consequence of building modular applications for which Cofoundry is a great helper. Could surely be made as an unrelated package.

HeyJoel commented 3 years ago

Closing as I think this is out of scope. Please add your thoughts if you think otherwise.