Vulnerability in EPiServer.Forms
I am wondering if it's possible to render
MVC Section can be your friend.
But that doesn't work for blocks
(Generally speaing, Blocks is a resuable component, Ideally, should not be used to render scripts)
If I am understanding it correctly, you will require to create a flag at rootlayout level to decide rather to render particular style or not rather at Block level.
Please see http://dodavinkeln.se/post/how-to-inject-a-script-for-a-block. But instead of using .AtFooter(), use .AtHeader(). Also use RequireStyle instead of RequireScript.
@Johan Cool, I have never tried this for blocks before as I probably have missed your blog :), just wondering, If its a collection of blocks on a page? will that script be included mutiple times?
You have not missed it, since you actually commented on it :)
No it will only be added once. You can also set up dependencies, so it's added before another resource and that they're added as well.
This worked perfectly, thanks Johan!