3

How can I enable line numbers in CSS output if I am using SASS? I found an article but I didn't quite understand where to make the modifications

http://pivotallabs.com/users/damon/blog/articles/765-standup-04-07-2009-we-have-questions#comments

Could you help me?

3 Answers 3

10

There's an option called :line_comments if you set this to true, Sass will place line numbers in your compiled output.

How to set this option depends on how you're using Sass. If it's in a Rails, Merb, or Rack application you can set Sass::Plugin.options[:line_comments] = true.

If you're using compass, set line_comments = false in your configuration file.

4
  • OK, I added 'line_comments = false' in the config.rb file, but still no change... I am using compass, what am I doing wrong?
    – hex
    Dec 1, 2009 at 14:00
  • 2
    In compass.config, sass_options = { :line_comments => true }
    – Kyle
    Dec 1, 2009 at 17:45
  • There was a bug in compass that was recently fixed. If you can upgrade to 0.10.0.pre2 or greater it will work. Or you can do it kyle's way. Dec 1, 2009 at 19:25
  • It worked! Thank you kyle and chris, I will update when it will be a stable version.
    – hex
    Dec 2, 2009 at 8:48
1

If you happen to be using Sprockets and the sprockets-sass gem, you may need to do it like this:

Sprockets::Sass.options[:line_comments] = true
0
0

Someone suggested this monkey-patch:

# Had to use this instead as per comment by @glebtv https://github.com/rails/sass-rails/issues/157
module Sass
    class Engine
      def initialize(template, options={})
        @options = self.class.normalize_options(options)
        @options[:debug_info] = true
        @template = template
      end
    end
end

The monkey-patch works, but I think this works even better: https://github.com/rails/sass-rails/pull/181

For now, you have to pull in rails-sass from the master branch.

group :development, :test do
  gem 'sass-rails', '~> 4.0.0', git: 'https://github.com/rails/sass-rails.git', branch: 'master'
end

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.