Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generating css file from new sass format (scss) with sinatra and haml

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

like image 516
Ben Avatar asked Oct 27 '10 04:10

Ben


People also ask

Is SCSS and sass the same?

SASS is used when we need an original syntax, code syntax is not required for SCSS. SASS follows strict indentation, SCSS has no strict indentation. SASS has a loose syntax with white space and no semicolons, the SCSS resembles more to CSS style and use of semicolons and braces are mandatory.

How do I run a SCSS file in HTML?

Add the following to the <head> tag of your HTML file. The extension we installed will compile the SASS file index. scss into CSS and store the compiled code in a new CSS file, also called index. css .

What is SCSS in CSS?

The term SCSS is an acronym for Sassy Cascading Style Sheets. It is basically a more advanced and evolved variant of the CSS language. Natalie Weizenbaum and Chris Eppstein created it, and Hampton Catlin designed it. It comes with more advanced features- thus often called Sassy CSS.


1 Answers

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.

like image 58
jayfallon Avatar answered Nov 15 '22 05:11

jayfallon