I am trying to follow Sass -> CSS converter code on Sass website.
template = File.load('stylesheets/sassy.sass')
sass_engine = Sass::Engine.new(template)
output = sass_engine.render
puts output
And I get this error while I’m trying to File.load
SyntaxError in PublishController#index
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:1: target of repeat operator is not specified: /* http:/
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:2: no .<digit> floating literal anymore; put 0 before dot
v2.0 | 20110126
^
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:2: syntax error, unexpected tINTEGER
v2.0 | 20110126
^
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:3: syntax error, unexpected ':', expecting $end
License: none (public domain) */
But when I do File.read, it works fine until output = sass_engine.render.
I get this error,
NoMethodError in PublishController#index
undefined method `[]' for nil:NilClass
What’s the difference between File.read and File.load? And if you know how to fix this problem in Sass, even better.
Well in the Ruby Kernel method
#loadit means evaluate the text loaded as code which is what it looks like is being done here.File.readloads the text as a String.From sass docs for
Sass::Engine.newSo do that.