0

I'm pretty new to ruby, but I'm even less familiar with LESS. Please, if you could, explain this as plain and simple as possible, because neither the documentation nor scattered blog entries have helped me in any way.

I'm using sinatra and I've got a file named main.less in my views folder. In my layout.haml a non-existent main.css is referenced. More exactly: /stylesheets/main.css. So I want to parse main.less using the less gem. I think I need to do something like this:

get '/stylesheets/main.css' do
  less ...
end

But I really can't figure out the exact code. Any hints or ideas?

1 Answer 1

2

Assuming you have the less gem installed, it would look like this:

get '/stylesheets/main.css' do
  less :main
end

By default this would look for main.less in your views/ directory under the directory you are running sinatra in. So, it's looking for views/main.less.

You can of course configure sinatra to load templates from elsewhere.

You can also configure sinatra with a very rails-like asset pipeline via the sinatra-asset-pipeline gem. Then your stylesheets would live in assets/ by default. I have a skeleton sinatra app here which shows sinatra-asset-pipeline in action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.