This repository was archived by the owner on Oct 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ class Railtie < ::Rails::Railtie
1111 # Initialize the load paths to an empty array
1212 config . sass . load_paths = [ ]
1313
14+ # Display line comments above each selector as a debugging aid
15+ config . sass . line_comments = true
16+
1417 # Set the default stylesheet engine
1518 # It can be overridden by passing:
1619 # --stylesheet_engine=sass
@@ -35,7 +38,7 @@ class Railtie < ::Rails::Railtie
3538 # Override stylesheet engine to the preferred syntax
3639 config . app_generators . stylesheet_engine syntax
3740
38- # Establish configuration defaults that are evironmental in nature
41+ # Establish configuration defaults that are environmental in nature
3942 # if config.sass.full_exception.nil?
4043 # # Display a stack trace in the css output when in development-like environments.
4144 # config.sass.full_exception = app.config.consider_all_requests_local
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ def call(input)
1010
1111 options = {
1212 filename : input [ :filename ] ,
13+ line_comments : line_comments? ,
1314 syntax : self . class . syntax ,
1415 load_paths : input [ :environment ] . paths ,
1516 importer : SassC ::Rails ::Importer ,
@@ -40,6 +41,7 @@ def self.included(base)
4041 def evaluate ( context , locals , &block )
4142 options = {
4243 filename : eval_file ,
44+ line_comments : line_comments? ,
4345 syntax : syntax ,
4446 load_paths : context . environment . paths ,
4547 importer : SassC ::Rails ::Importer ,
@@ -77,6 +79,10 @@ def config_options
7779 def sass_style
7880 ( Rails . application . config . sass . style || :expanded ) . to_sym
7981 end
82+
83+ def line_comments?
84+ Rails . application . config . sass . line_comments
85+ end
8086 end
8187
8288 class ScssTemplate < SassTemplate
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
2323 spec . add_development_dependency "rake" , "~> 10.0"
2424 spec . add_development_dependency 'mocha'
2525
26- # unfortunately we require sass for now, so that we can
27- # reuse portions of the sprockets template
26+ # Unfortunately we require sass for now, so that we can
27+ # reuse portions of the Sprockets template
2828 spec . add_dependency 'sass'
2929 spec . add_dependency "sassc" , "~> 1.5"
3030
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ def setup
1717 @app . config . sass . preferred_syntax = :scss
1818 @app . config . sass . load_paths = [ ]
1919
20+ # Not actually a default, but it makes assertions more complicated
21+ @app . config . sass . line_comments = false
22+
2023 Rails . backtrace_cleaner . remove_silencers!
2124 end
2225
@@ -161,6 +164,15 @@ def test_style_config_item_is_honored
161164 assert_equal :nested , Rails . application . config . sass . style
162165 end
163166
167+ def test_line_comments_active_in_dev
168+ @app . config . sass . line_comments = true
169+ initialize_dev!
170+
171+ css_output = render_asset ( "css_scss_handler.css.scss" )
172+ assert_match %r{/* line 1} , css_output
173+ assert_match %r{.+/sassc-rails/test/dummy/app/assets/stylesheets/css_scss_handler.css.scss} , css_output
174+ end
175+
164176 def test_context_is_being_passed_to_erb_render
165177 initialize!
166178
You can’t perform that action at this time.
0 commit comments