문제

I am writing a sinatra app with haml and sass. When I try to link in the stylesheet with a scss extension located in my views folder I get the following error: NoMethodError at /nav.css undefined method `scss'

Here is my get method

get '/nav.css' do 
    content_type 'text/css', :charset => 'utf-8'
    scss :nav
end

I have only gotten this to work when I switch to the older sass syntax. I also have to change the nav.scss to nav.sass and the get method to sass :nav

I have also tried just having sass :nav with nav.scss and sass :nav with nav.sass but still scss syntax

도움이 되었습니까?

해결책

Excerpt from Sinatra README

## You'll need to require haml or sass in your app
require 'sass'

get '/stylesheet.css' do
  scss :stylesheet
end

Are you required the sass gem?

What version of Sinatra you use. Support for scss was added in 2010.09.01 (same day version was increased from 1.0 to 1.1), perhaps you need and update.

다른 팁

I don't use the above code from the README, just put the following in your app.rb file after updating your gem.

get '/stylesheets/:name.css' do
 content_type 'text/css', :charset => 'utf-8'
 scss(:"stylesheets/#{params[:name]}")
end

Restart your server and you're all set. Happy Scssing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top