简体   繁体   English

如何在Rails 3.1 Asset Pipeline中更少地使用变量

[英]How do I use variables in less with the Rails 3.1 Asset Pipeline

I am converting a number of less files into a rails app, and running into problems with the processing of variables and other less features. 我正在将大量较少的文件转换为Rails应用程序,并且遇到了变量和其他较少功能的处理问题。

I require my assets in application.css, but when viewing the page see the following error: 我在application.css中需要我的资产,但是在查看页面时看到以下错误:

Less::ParseError: variable @light-border is undefined
  (in tokens.css.less
Served asset /tokens.css - 500 Internal Server Error

I have a less file that defines all my variables and several other files that define various mixins. 我有一个较少的文件,它定义了我所有的变量,还有几个其他的文件,定义了各种混合。

The problem also seems to affect the mixins - looks like the less files are being processed individually, but not as a single context ... hence the variable and mixin errors. 这个问题似乎也影响了mixin-看起来较少的文件是单独处理的,而不是作为单个上下文处理的……因此出现了变量和mixin错误。 Individual files will render, but not include the various components and variables. 单个文件将呈现,但不包括各种组件和变量。

Is there a trick to getting this working in Rails? 使它在Rails中工作是否有技巧?

I added the less-rails gem and it seems to work now. 我添加了less-rails gem,它现在似乎可以正常工作。 I think the asset pipeline doesn't actually support more than rudimentary less use. 我认为资产流水线实际上所提供的支持并没有超出基本要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM