Created
November 15, 2011 16:16
-
-
Save rdumont/1367469 to your computer and use it in GitHub Desktop.
Using SquishIt pre-1.8.1 with ASP.NET MVC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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