LESS 循环函数未在 Rails 4 中编译
LESS loop function not compiling in Rails 4
我似乎无法解决为什么没有编译 less 循环函数的问题。我已经验证代码在 winless.org and lesstester 上都有效。这是下面的代码(我已将其缩短):
@action-color: #00ffff; //aqua
@adventure-color: #000000; //black
@animation-color: #0000ff; //blue
.genre-names(
~"action",
~"adventure",
~"animation";
);
.genre-names(@list, @index: 1) when (isstring(extract(@list, @index))) {
@genre: extract(@list, @index);
.@{genre} {
background-color: ~'@{@{genre}-color}';
}
.genre-names(@list, (@index + 1));
}
编译后的输出应该是这样的:
.action {
background-color: #00ffff;
}
.adventure {
background-color: #000000;
}
.animation {
background-color: #0000ff;
}
它位于 colors.css.less
,位于 assets/stylesheets
目录中。我已将代码移至不同的 less 工作表,但仍然无法工作。
我正在使用 rails-less-bootstrap gem,否则它可以正常工作。作为此 gem 安装的依赖项,我还有以下 gems:
less (2.3.3)
less-rails (2.3.3)
less-rails-bootstrap (3.0.2)
libv8 (3.16.14.7 x86_64-darwin-14)
sprockets (2.12.3)
sprockets-rails (2.2.4)
therubyracer (0.12.1)
我已尝试清除缓存和 sprocket 文件并进行预编译。编译后的代码只是不显示。请帮忙!
代表@seven-phases-max 发帖,@seven-phases-max 在我原来的评论中回答了这个问题post。这是因为我使用的 less-rails-bootstrap
gem 使用了旧版本的 Less (1.3.3)。
我似乎无法解决为什么没有编译 less 循环函数的问题。我已经验证代码在 winless.org and lesstester 上都有效。这是下面的代码(我已将其缩短):
@action-color: #00ffff; //aqua
@adventure-color: #000000; //black
@animation-color: #0000ff; //blue
.genre-names(
~"action",
~"adventure",
~"animation";
);
.genre-names(@list, @index: 1) when (isstring(extract(@list, @index))) {
@genre: extract(@list, @index);
.@{genre} {
background-color: ~'@{@{genre}-color}';
}
.genre-names(@list, (@index + 1));
}
编译后的输出应该是这样的:
.action {
background-color: #00ffff;
}
.adventure {
background-color: #000000;
}
.animation {
background-color: #0000ff;
}
它位于 colors.css.less
,位于 assets/stylesheets
目录中。我已将代码移至不同的 less 工作表,但仍然无法工作。
我正在使用 rails-less-bootstrap gem,否则它可以正常工作。作为此 gem 安装的依赖项,我还有以下 gems:
less (2.3.3)
less-rails (2.3.3)
less-rails-bootstrap (3.0.2)
libv8 (3.16.14.7 x86_64-darwin-14)
sprockets (2.12.3)
sprockets-rails (2.2.4)
therubyracer (0.12.1)
我已尝试清除缓存和 sprocket 文件并进行预编译。编译后的代码只是不显示。请帮忙!
代表@seven-phases-max 发帖,@seven-phases-max 在我原来的评论中回答了这个问题post。这是因为我使用的 less-rails-bootstrap
gem 使用了旧版本的 Less (1.3.3)。