Skip to content

Instantly share code, notes, and snippets.

@johngrant
Created March 24, 2015 18:27
Show Gist options
  • Save johngrant/f3091413b3b594ea137d to your computer and use it in GitHub Desktop.
Save johngrant/f3091413b3b594ea137d to your computer and use it in GitHub Desktop.
Prototype code used to enumerate the files in a bundle at runtime then serialize to JS array the bundle or the contents based on the DEBUG symbols
@{
var includes = "[]";
var bundleName = "~/bundles/agent-profile";
if (!BundleTable.EnableOptimizations)
{
var resolver = new BundleResolver();
var url = resolver.GetBundleContents(bundleName).Select(s => string.Format("'{0}'", Url.Content(s)));
includes = "[" + string.Join(",", url) + "]";
}
else
{
var location = Url.Content(bundleName);
includes = "['" + location + "']";
}
}
@section scriptloader {
var includes = @Html.Raw(includes);
$script(['@Url.Content("~/bundles/ko-js")'], 'knockout');
$script.ready('knockout', function() {
$script(includes,'profile');
$script.ready('profile', function() {
var profile = new nplay.controllers.profile();
profile.initialize().done(function (app) {
window.app = app;
});
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment