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

Set line-comments by default like sass-rails #24

Merged
merged 1 commit into from
Jul 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -40,6 +41,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 Down Expand Up @@ -77,6 +79,10 @@ def config_options
def sass_style
(Rails.application.config.sass.style || :expanded).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.5"

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 @@ -161,6 +164,15 @@ def test_style_config_item_is_honored
assert_equal :nested, 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