Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sass no longer working in Sinatra — maybe something to do with tilt #91

Closed
davesag opened this issue May 25, 2011 · 25 comments
Closed

Comments

@davesag
Copy link

davesag commented May 25, 2011

I have updated all the gems in my Sinatra project and now my loading of sass templates doesn't work.

I have a route

get '/css/:sheet.css' do 
    content_type 'text/css', :charset => 'utf-8' 
    sass params[:sheet].to_sym 
end 

and when the code hits the sass line it throws

NoMethodError - undefined method `engine_options' for Sass::Plugin:Module: 
/Library/Ruby/Gems/1.8/gems/tilt-1.3.1/lib/tilt/css.rb:21:in `prepare' 
/Library/Ruby/Gems/1.8/gems/tilt-1.3.1/lib/tilt/template.rb:69:in `initialize' 
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:599:in `new' 
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:599:in `compile_template' 
/Library/Ruby/Gems/1.8/gems/tilt-1.3.1/lib/tilt.rb:127:in `fetch'  /Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:578:in `compile_template' 
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:562:in `render' 
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:468:in `sass' 
./showpony.rb:376:in `GET /css/:sheet.css'

Konstantin asked me to raise it as an issue here.

Cheers

Dave

@josh
Copy link
Contributor

josh commented May 25, 2011

Can you try on tilt/master. Curious if this commit 0f37285 fixes the issue.

@davesag
Copy link
Author

davesag commented May 25, 2011

Just looking at the code that certainly looks like it would fix it. I'm not quite sure how I'd tell my Sinatra to pull in the code from tilt/master to be truthful — sorry in many ways a ruby newbie still.

@ghost ghost assigned rkh May 25, 2011
@rkh
Copy link
Collaborator

rkh commented May 25, 2011

One related Sass test is failing for me on master, am on it.

@davesag
Copy link
Author

davesag commented May 25, 2011

Sweet. After midnight here and I have to hike up a mountain in the morning, so will check back tomorrow.

thanks

d

@rkh
Copy link
Collaborator

rkh commented May 25, 2011

Fixed the test with 9e9643e, but it shouldn't be related.

@josh
Copy link
Contributor

josh commented May 25, 2011

I don't want people to have to require 'sass/plugin' beforehand to use the handler.

@rkh
Copy link
Collaborator

rkh commented May 25, 2011

I think you don't have to, but one test, the one failing test, references Sass::Plugin directly.

@josh
Copy link
Contributor

josh commented May 25, 2011

Gotcha

@davesag
Copy link
Author

davesag commented May 26, 2011

Will there be a new release with this fix soon?

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

Does it fix the issue for you? If so, probably as soon as @rtomayko has time to push it to gemcutter.

@davesag
Copy link
Author

davesag commented May 26, 2011

Being in many ways a ruby newbie still, I was just about to go read up on how I'd take your current master build, turn it into a gem and then (guessing here) would I put that gem in my project's lib directory and assume it overrides any other version, or is there a better way?

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

You could use Bundler. Create a file called Gemfile in your project directory with the following content:

gem 'sinatra'
gem 'tilt', :git => 'git://github.com/rtomayko/tilt.git'
gem 'sass'
# ...  all your other dependencies ...

And then run:

gem install bundler
bundle install
bundle exec ruby app.rb # or whatever you use to start your app

Or you could just build and install it globally:

git clone git://github.com/rtomayko/tilt.git
cd tilt
gem build *.gemspec
gem install *.gem

@davesag
Copy link
Author

davesag commented May 26, 2011

I use Bundler already but had no idea you could pull things right from a git repo. That's cool! Thanks. So using the fresh build of tilt's master I get the same error.

NoMethodError - undefined method `engine_options' for Sass::Plugin:Module:
/Library/Ruby/Gems/1.8/bundler/gems/tilt-9e9643e5fd4e/lib/tilt/css.rb:21:in `prepare'
/Library/Ruby/Gems/1.8/bundler/gems/tilt-9e9643e5fd4e/lib/tilt/template.rb:69:in `initialize'
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:599:in `new'
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:599:in `compile_template'
/Library/Ruby/Gems/1.8/bundler/gems/tilt-9e9643e5fd4e/lib/tilt.rb:127:in `fetch'
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:578:in `compile_template'
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:562:in `render'
/Library/Ruby/Gems/1.8/gems/sinatra-1.2.6/lib/sinatra/base.rb:468:in `sass'
./showpony.rb:376:in `GET /css/:sheet.css'

Guess that didn't fix it.

@davesag
Copy link
Author

davesag commented May 26, 2011

In your code

options = ::Sass::Plugin.engine_options(sass_options)

but in https://github.com/nex3/sass/blob/master/lib/sass/plugin.rb there is an options method but no engine_options method.

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

I have a hard time reproducing this. What Sass version do you use? In 3.1.1 (the current version) Sass::Plugin.engine_options is defined, both in the standalone version and the version included in Haml. It's also defined in 3.2.0.alpha.0 (current master).

@davesag
Copy link
Author

davesag commented May 26, 2011

Using Sass 3.1.1

D

On 26/05/2011, at 9:40 PM, rkhreply@reply.github.com wrote:

I have a hard time reproducing this. What Sass version do you use? In 3.1.1 (the current version) Sass::Plugin.engine_options is defined, both in the standalone version and the version included in Haml.

Reply to this email directly or view it on GitHub:
#91 (comment)

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

Goes like this: Sass::Plugin#method_missing triggers Sass::Plugin::Compiler#engine_options. Seems like for some reason you either have the wrong compiler object in there or Sass::Plugin::Compiler has no engine_options for you. No idea what triggers this. @chriseppstein, @nex3: any idea?

@davesag
Copy link
Author

davesag commented May 26, 2011

Looking in https://github.com/nex3/sass/blob/master/lib/sass/plugin.rb I can't see any engine_options method. What am I missing? I do see engine_options in https://github.com/nex3/sass/blob/master/lib/sass/plugin/compiler.rb though but that's not what's getting called by tilt is it?

see line 21 of https://github.com/rtomayko/tilt/blob/master/lib/tilt.rb

options = ::Sass::Plugin.engine_options(sass_options)

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

@davesag yes, it is, through the method_missing in Sass::Plugin.

@rkh
Copy link
Collaborator

rkh commented May 26, 2011

I cannot reproduce this with your code, neither with Sinatra 1.2.6 nor with Sinatra 1.3.0, both tested with Sass 3.1.1 and master.

@amrnt
Copy link

amrnt commented May 26, 2011

It works fine with require 'sass/plugin'.

@josh
Copy link
Contributor

josh commented May 26, 2011

I kind of just want to revert all this plugin shit.

@chriseppstein
Copy link

@josh I think that would be fine We are not using the sass/plugin in rails. Configuration is done via config.sass in application config blocks.

@josh
Copy link
Contributor

josh commented May 26, 2011

Reverted a4fb484

This restores the handler to how it was in 1.3.

@josh josh closed this as completed May 26, 2011
@davesag
Copy link
Author

davesag commented May 26, 2011

hey guys - i just tested my code with 1.3.2 and voila - all working and happy. many thanks.

d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants