.LESS与剃刀一起 [英] .LESS together with Razor

查看:184
本文介绍了.LESS与剃刀一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能与.LESS(类似于SASS一起使用的Razor视图引擎(ASP.NET MVC) - http://lesscss.org/ 为.NET),因为他们使用的是@blah两者兼而有之?

Is it possible to use Razor View Engine (ASP.NET MVC) together with .LESS (similar to SASS - http://lesscss.org/ 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!

  • 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与剃刀一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆