Created
October 20, 2010 21:31
-
-
Save CoreyKaylor/637375 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
<link href="~/Content/Site.css" type="text/css" rel="stylesheet" /> | |
<script src="~/Scripts/jquery-1.4.1.js" type="text/javascript" language="javascript" /> |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<bindings> | |
<element name="Greetings">"Hello from binding!"</element> | |
<element name="link"> | |
HtmlHelper.RenderLinkImport('@href', '@type', '@rel') | |
</element> | |
<element name="script"> | |
HtmlHelper.RenderScriptImport('@src', '@type', '@language') | |
</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
private static readonly string _version; | |
static ViewExtensions() | |
{ | |
var version = Assembly.GetExecutingAssembly().GetName().Version; | |
_version = "{0}{1}{2}{3}".ToFormat(version.Major, version.MajorRevision, version.Minor, version.MinorRevision); | |
} | |
public static string RenderLinkImport(this HtmlHelper helper, string href, string type, string rel) | |
{ | |
return @"<link href=""{0}?v={1}"" type=""{2}"" rel=""{3}"" />".ToFormat(href, _version, type, rel); | |
} | |
public static string RenderScriptImport(this HtmlHelper helper, string src, string type, string language) | |
{ | |
#if !DEBUG | |
if(src.EndsWith(".js")) | |
src = src.Insert(src.IndexOf(".js"), ".min"); | |
#endif | |
return @"<link src=""{0}?v={1}"" type=""{2}"" language=""{3}"" />".ToFormat(src, _version, type, language); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment