是否有可能与.LESS(类似于SASS一起使用的Razor视图引擎(ASP.NET MVC) - lesscss/ 为.NET),因为他们使用的是@blah两者兼而有之?
Is it possible to use Razor View Engine (ASP.NET MVC) together with .LESS (similar to SASS - lesscss/ for .NET), since they're both using "@blah"?
我想实现的是创造.LESS css文件,夹杂着剃刀。
What I want to achieve is to create .LESS css files, mixed with Razor.
更新:
对不起,作为一个有点不确定的。我想要做的就是使用的Razor视图引擎中的.LESS(dotlesscss)css文件。这将是很好的,以如通过站点设置,如主题从管理到CSS文件定制。
Sorry for being a bit unspecific. What I want to do is to use Razor View Engine WITHIN the .less (dotlesscss) css files. This would be nice in order to e.g. pass site-settings like Theme customized from an admin into the css file.
问题是,语法会崩溃。
另一种方法是使用C#或其他一些视图引擎来代替。
An alternative is to use C# or some other View Engine instead.
推荐答案您应该考虑使用贾斯汀Etheredge的SquishIt库。它不仅包括dotlesscss库,它将结合并轻松运行如下的CSS和Javascript!
You should consider using Justin Etheredge's SquishIt library. Not only does it include the dotlesscss library, it will combine and minify your CSS and Javascript with ease!
- 有关SquishIt博客文章 在GitHub上
- 来源$ C $ C
- Blog post regarding SquishIt
- Source code on GitHub
以下code将结合,缩小和LESSify所有引用到一个CSS文件中的CSS文件。它会做同样的JavaScript文件。
The following code will combine, minify and LESSify all the CSS files referenced into one CSS file. It will do the same with the Javascript files.
@MvcHtmlString.Create( SquishIt.Framework.Bundle.Css() .Add("~/media/css/reset.css") .Add("~/media/css/style.less") .Add("~/media/css/handheld.css") .Render("~/media/css/combined_#.css")) @MvcHtmlString.Create( SquishIt.Framework.Bundle.JavaScript() .Add("~/media/js/geo.js") .Add("~/media/js/jquery-1.4.4.js") .Add("~/media/js/jquery.unobtrusive-ajax.js") .Add("~/media/js/jquery.validate.js") .Add("~/media/js/jquery.validate.unobtrusive.js") .Render("~/media/js/combined_#.js"))的输出看起来是这样的:的
<link rel="stylesheet" type="text/css" href="/media/css/combined_312454.css" /> <script type="text/javascript" href="/media/js/combined_312454.js"></script>UPDATE(超过1年后)... 结果你可能想看看另一个项目是盒式其中pretty多所做的一切SquishIt做(及以上)。
UPDATE (Over 1 year later)... Another project you might want to look at is Cassette which pretty much does everything SquishIt does (and more).
更多推荐
.LESS与剃刀一起
发布评论