I'm building a framework on top of ASP.NET MVC 4. I like the new bundling feature in MVC4 but I'm running into an issue and I'm not sure if the new bundling features address this scenario.
My layout view is rendering it's script bundles at the bottom of the page before </body>
.
Since my project is a framework, the view doesn't know all of the bundles that the page will need. My project is making heavy use of editor templates, which may need to include some javascript, but can't render it in the editor template itself because:
- The script needs to be included only once and the editor template may be rendered more than once.
- The script may depend on other javascript libraries like jQuery, which haven't been included yet (they are rendered at the bottom of the page).
So, what I'd like to do is something like this in an editor template:
@Scripts.TriggerInclusion("~/path/to/bundle/that/this/editor/needs")
And that would cause the bundle script tag to be rendered towards the end of the page only once.
I could go to the trouble of building this into my project's infrastructure, but I'm hoping that this sort of thing is already supported somehow. Thanks!