Skip to content

Commit

Permalink
Set line-comments by default like sass-rails
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Ocampo-Gooding committed Jun 30, 2015
1 parent ef1140e commit 8876da8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/sassc/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Railtie < ::Rails::Railtie
# Initialize the load paths to an empty array
config.sass.load_paths = []

# Display line comments above each selector as a debugging aid
config.sass.line_comments = true

# Set the default stylesheet engine
# It can be overridden by passing:
# --stylesheet_engine=sass
Expand All @@ -35,7 +38,7 @@ class Railtie < ::Rails::Railtie
# Override stylesheet engine to the preferred syntax
config.app_generators.stylesheet_engine syntax

# Establish configuration defaults that are evironmental in nature
# Establish configuration defaults that are environmental in nature
# if config.sass.full_exception.nil?
# # Display a stack trace in the css output when in development-like environments.
# config.sass.full_exception = app.config.consider_all_requests_local
Expand Down
6 changes: 6 additions & 0 deletions lib/sassc/rails/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def call(input)

options = {
filename: input[:filename],
line_comments: line_comments?,
syntax: self.class.syntax,
load_paths: input[:environment].paths,
importer: SassC::Rails::Importer,
Expand Down Expand Up @@ -41,6 +42,7 @@ def self.included(base)
def evaluate(context, locals, &block)
options = {
filename: eval_file,
line_comments: line_comments?,
syntax: syntax,
load_paths: context.environment.paths,
importer: SassC::Rails::Importer,
Expand All @@ -65,6 +67,10 @@ def sass_style
style = Rails.application.config.sass.style || :expanded
"sass_style_#{style}".to_sym
end

def line_comments?
Rails.application.config.sass.line_comments
end
end

class ScssTemplate < SassTemplate
Expand Down
4 changes: 2 additions & 2 deletions sassc-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency 'mocha'

# unfortunately we require sass for now, so that we can
# reuse portions of the sprockets template
# Unfortunately we require sass for now, so that we can
# reuse portions of the Sprockets template
spec.add_dependency 'sass'
spec.add_dependency "sassc", "~> 1.3"

Expand Down
12 changes: 12 additions & 0 deletions test/sassc_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def setup
@app.config.sass.preferred_syntax = :scss
@app.config.sass.load_paths = []

# Not actually a default, but it makes assertions more complicated
@app.config.sass.line_comments = false

Rails.backtrace_cleaner.remove_silencers!
end

Expand Down Expand Up @@ -166,6 +169,15 @@ def test_style_config_item_is_not_honored_if_environment_is_not_development
assert_equal :compressed, Rails.application.config.sass.style
end

def test_line_comments_active_in_dev
@app.config.sass.line_comments = true
initialize_dev!

css_output = render_asset("css_scss_handler.css.scss")
assert_match %r{/* line 1}, css_output
assert_match %r{.+/sassc-rails/test/dummy/app/assets/stylesheets/css_scss_handler.css.scss}, css_output
end

def test_context_is_being_passed_to_erb_render
initialize!

Expand Down

0 comments on commit 8876da8

Please sign in to comment.