.LESS与剃刀一起

编程入门 行业动态 更新时间:2024-10-24 18:26:23
本文介绍了.LESS与剃刀一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能与.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与剃刀一起

本文发布于:2023-11-27 06:37:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636989.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:剃刀

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!