Skip to content

Commit 8876da8

Browse files
author
Edward Ocampo-Gooding
committed
Set line-comments by default like sass-rails
1 parent ef1140e commit 8876da8

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

lib/sassc/rails/railtie.rb

+4-1
Original file line numberDiff line numberDiff 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

lib/sassc/rails/template.rb

+6
Original file line numberDiff line numberDiff 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,
@@ -41,6 +42,7 @@ def self.included(base)
4142
def evaluate(context, locals, &block)
4243
options = {
4344
filename: eval_file,
45+
line_comments: line_comments?,
4446
syntax: syntax,
4547
load_paths: context.environment.paths,
4648
importer: SassC::Rails::Importer,
@@ -65,6 +67,10 @@ def sass_style
6567
style = Rails.application.config.sass.style || :expanded
6668
"sass_style_#{style}".to_sym
6769
end
70+
71+
def line_comments?
72+
Rails.application.config.sass.line_comments
73+
end
6874
end
6975

7076
class ScssTemplate < SassTemplate

sassc-rails.gemspec

+2-2
Original file line numberDiff line numberDiff 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.3"
3030

test/sassc_rails_test.rb

+12
Original file line numberDiff line numberDiff 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

@@ -166,6 +169,15 @@ def test_style_config_item_is_not_honored_if_environment_is_not_development
166169
assert_equal :compressed, Rails.application.config.sass.style
167170
end
168171

172+
def test_line_comments_active_in_dev
173+
@app.config.sass.line_comments = true
174+
initialize_dev!
175+
176+
css_output = render_asset("css_scss_handler.css.scss")
177+
assert_match %r{/* line 1}, css_output
178+
assert_match %r{.+/sassc-rails/test/dummy/app/assets/stylesheets/css_scss_handler.css.scss}, css_output
179+
end
180+
169181
def test_context_is_being_passed_to_erb_render
170182
initialize!
171183

0 commit comments

Comments
 (0)