Created
May 26, 2011 14:06
-
-
Save robertmilne/993213 to your computer and use it in GitHub Desktop.
This file contains 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
public static class BindingExtensions | |
{ | |
public static MvcHtmlString Script(this HtmlHelper helper, string innerHtml, Dictionary<string, object> attributes) | |
{ | |
if (!System.Diagnostics.Debugger.IsAttached) | |
innerHtml = new Microsoft.Ajax.Utilities.Minifier().MinifyJavaScript(innerHtml); | |
var builder = new TagBuilder("script"); | |
builder.MergeAttributes(attributes); | |
builder.InnerHtml = innerHtml; | |
return MvcHtmlString.Create(builder.ToString()); | |
} | |
public static MvcHtmlString Style(this HtmlHelper helper, string innerHtml, Dictionary<string, object> attributes) | |
{ | |
if (!System.Diagnostics.Debugger.IsAttached) | |
innerHtml = new Microsoft.Ajax.Utilities.Minifier().MinifyStyleSheet(innerHtml); | |
var builder = new TagBuilder("style"); | |
builder.MergeAttributes(attributes); | |
builder.InnerHtml = innerHtml; | |
return MvcHtmlString.Create(builder.ToString()); | |
} | |
} |
This file contains 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
<bindings> | |
<element name="style">Html.Style('child::*', new System.Collections.Generic.Dictionary<string,object>{{'@*'}})</element> | |
<element name="script">Html.Script('child::*', new System.Collections.Generic.Dictionary<string,object>{{'@*'}})</element> | |
</bindings> |
This file contains 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
<style type="text/css">#dashboard{margin:1em;padding:1em;border:1px solid #222}</style> | |
<script type="text/javascript">$(function(){$("#dashboard").load("/Test/Dashboard")})</script> |
This file contains 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
<content:head> | |
<style type="text/css" cache.expires="1200" cache="System.Diagnostics.Debugger.IsAttached"> | |
#dashboard | |
{ | |
margin: 1em; | |
padding: 1em; | |
border: 1px solid #222; | |
} | |
</style> | |
</content:head> | |
<content:scripts> | |
<script if="bool.Parse('false')" src="/Scripts/jquery-1.4.2.min.js" type="text/javascript"></script> | |
<script type="text/javascript" cache.expires="1200" cache="System.Diagnostics.Debugger.IsAttached"> | |
$(function () { | |
// We don't need no stinkin' comments | |
$("#dashboard").load("!{Url.Action(MVC.Test.Dashboard())}"); | |
}); | |
</script> | |
</content:scripts> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment