#18419: Fixing !IE conditional comments

Work Item: 18419

--HG--
branch : 1.x
This commit is contained in:
miguelerm
2012-02-16 14:36:28 -08:00
parent e2be72150e
commit 4cefffe568
@@ -24,6 +24,8 @@ namespace Orchard.UI.Resources {
private List<String> _footScripts; private List<String> _footScripts;
private IEnumerable<IResourceManifest> _manifests; private IEnumerable<IResourceManifest> _manifests;
private const string NotIE = "!IE";
private static string ToAppRelativePath(string resourcePath) { private static string ToAppRelativePath(string resourcePath) {
if (!String.IsNullOrEmpty(resourcePath) && !Uri.IsWellFormedUriString(resourcePath, UriKind.Absolute)) { if (!String.IsNullOrEmpty(resourcePath) && !Uri.IsWellFormedUriString(resourcePath, UriKind.Absolute)) {
resourcePath = VirtualPathUtility.ToAppRelative(resourcePath); resourcePath = VirtualPathUtility.ToAppRelative(resourcePath);
@@ -58,18 +60,32 @@ namespace Orchard.UI.Resources {
public static void WriteResource(TextWriter writer, ResourceDefinition resource, string url, string condition, Dictionary<string, string> attributes) { public static void WriteResource(TextWriter writer, ResourceDefinition resource, string url, string condition, Dictionary<string, string> attributes) {
if (!string.IsNullOrEmpty(condition)) { if (!string.IsNullOrEmpty(condition)) {
if (condition == NotIE) {
writer.WriteLine("<!--[if " + condition + "]>"); writer.WriteLine("<!--[if " + condition + "]>");
} }
else {
writer.WriteLine("<!--[if " + condition + "]>-->");
}
}
var tagBuilder = GetTagBuilder(resource, url); var tagBuilder = GetTagBuilder(resource, url);
if (attributes != null) { if (attributes != null) {
// todo: try null value // todo: try null value
tagBuilder.MergeAttributes(attributes, true); tagBuilder.MergeAttributes(attributes, true);
} }
writer.WriteLine(tagBuilder.ToString(resource.TagRenderMode)); writer.WriteLine(tagBuilder.ToString(resource.TagRenderMode));
if (!string.IsNullOrEmpty(condition)) { if (!string.IsNullOrEmpty(condition)) {
if (condition == NotIE) {
writer.WriteLine("<!--<![endif]-->");
}
else {
writer.WriteLine("<![endif]-->"); writer.WriteLine("<![endif]-->");
} }
} }
}
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders) { public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders) {
_providers = resourceProviders; _providers = resourceProviders;