在Sinatra应用程序中解析LESS选项 [英] Parsing LESS options in a Sinatra app

查看:82
本文介绍了在Sinatra应用程序中解析LESS选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法更改LESS用于包括导入的路径.我的路线文件有

I'm having trouble changing the path that LESS uses to include imports. My routes file has

get "/css/main.css" do
  less :main, :paths => ["public/css"]
end

但是,如果我在样式表中包含带有@import的外部less文件,LESS编译器将找不到该文件.我已经在views路径和public/css目录中都放置了一个副本,但是仍然找不到它.但是,它可以在public\css中找到普通的.css文件.

However, if I include an external less file with @import in my stylesheet the LESS compiler cannot find the file. I've placed a copy in both the views path and public/css directories, but it still can't find it. It CAN however find plain .css files in public\css.

推荐答案

我今天遇到了这个问题,并且能够像这样解决它:

I hit this today, and was able to solve it like so:

require 'less'
require 'sinatra/base'

class App < Sinatra::Base
  # Make LESS @import statements work
  Less.paths << settings.views

  # Use LESS for CSS
  get '/stylesheets/:style.css' do
    less(params[:style].to_sym)
  end
end

这篇关于在Sinatra应用程序中解析LESS选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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