与IE条件注释MVC4捆绑/缩小 [英] MVC4 bundling/minification with IE conditional comments
问题描述
我想使用MVC4的新的捆绑和缩小。
I am trying to use MVC4's new "bundling and minification".
有关IE条件注释,我还在做旧的方式:<!code>&LT; - [如果LT IE 9]&GT;&LT;链接HREF = ... /&GT;&LT; ![ENDIF] - &GT; 或&LT;! - [如果LT IE 9&GT; @ Styles.Render(〜/富)&LT;! ENDIF] - 方式&gt;
但我似乎并没有得到自动调试/发布处理
For IE conditional comments, I'm still doing it the old way: <!--[if lt IE 9]><link href=.../><![endif]-->
or <!--[if lt IE 9]>@Styles.Render("~/foo")<![endif]-->
but I don't seem to get the automatic debug/release handling.
有一个内置的方式做到这一点?如何在别人这样做呢?
Is there a built-in way to do this? How are others doing this?
编辑:结果
同时这将是伟大的,是能够包括&LT; NOSCRIPT方式&gt;
渲染输出(用于回退)的内部代码
Also it would be great to be able to include <noscript>
tags inside the rendered output (used for fallbacks).
推荐答案
直到我找到更好的方法,我做了一个名为捆绑
适配器类,它有方法:
Until I find a better way, I made an adaptor class called Bundles
, which has the method:
public static IHtmlString RenderStylesIe(string ie, params string[] paths) {
var tag = string.Format("<!--[if {0}]>{1}<![endif]-->", ie, Styles.Render(paths));
return new MvcHtmlString(tag);
}
有用于脚本的类似方法。视图称他们为这样的:
There is a similar method for scripts. A view calls them as such:
@Bundles.RenderStylesIe("lt IE 9", "~/Content/foo")
@Bundles.RenderScriptsIe("lte IE 7", "~/Scripts/bar")
如果有更好的办法,我AP preciate的意见。
If there is a better way, I'd appreciate the advice.
这篇关于与IE条件注释MVC4捆绑/缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!