Skip to content

Instantly share code, notes, and snippets.

@rdumont
Created November 15, 2011 16:16
Show Gist options
  • Save rdumont/1367469 to your computer and use it in GitHub Desktop.
Save rdumont/1367469 to your computer and use it in GitHub Desktop.
Using SquishIt pre-1.8.1 with ASP.NET MVC
@using MvcApplication1.Extensions
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
@Html.BundleCss().Add(
"~/Content/Site.css"
).MvcRender("~/Content/styles_#.css")
@Html.BundleJavaScript().Add(
"~/Scripts/jquery-1.5.1.min.js",
"~/Scripts/modernizr-1.7.min.js"
).MvcRender("~/Scripts/scripts_#.css")
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
using System.Web.Mvc;
using SquishIt.Framework.Base;
using SquishIt.Framework.Css;
using SquishIt.Framework.JavaScript;
namespace MvcApplication1.Extensions
{
public static class SquishItExtensions
{
public static CSSBundle BundleCss(this HtmlHelper htmlHelper)
{
return new CSSBundle();
}
public static JavaScriptBundle BundleJavaScript(this HtmlHelper htmlHelper)
{
return new JavaScriptBundle();
}
public static MvcHtmlString MvcRender<T>(this BundleBase<T> bundle, string renderTo) where T : BundleBase<T>
{
return MvcHtmlString.Create(bundle.Render(renderTo));
}
public static MvcHtmlString MvcRenderNamed<T>(this BundleBase<T> bundle, string name) where T : BundleBase<T>
{
return MvcHtmlString.Create(bundle.RenderNamed(name));
}
public static MvcHtmlString MvcRenderCachedAssetTag<T>(this BundleBase<T> bundle, string name) where T : BundleBase<T>
{
return MvcHtmlString.Create(bundle.RenderCachedAssetTag(name));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment