New CLI option --syntax (-x) and configuration option (preferred_syntax) that govern what sass syntax is used when adding stylesheets to a project.
This commit is contained in:
parent
2eda8a6822
commit
2680d23190
@ -39,6 +39,10 @@ module Compass
|
||||
self.options[:pattern] = framework[1]
|
||||
end
|
||||
|
||||
opts.on("-x", "--syntax SYNTAX", [:sass, :scss], "Specify the syntax to use when generating stylesheets.", "One of sass or scss. Defaults to scss.") do |syntax|
|
||||
self.options[:preferred_syntax] = syntax
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
|
@ -16,6 +16,10 @@ Example:
|
||||
|
||||
Options:
|
||||
}
|
||||
opts.on("-x", "--syntax SYNTAX", [:sass, :scss], "Specify the syntax to use when generating stylesheets.", "One of sass or scss. Defaults to scss.") do |syntax|
|
||||
self.options[:preferred_syntax] = syntax
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +35,8 @@ module Compass
|
||||
:asset_host,
|
||||
:asset_cache_buster,
|
||||
:line_comments,
|
||||
:color_output
|
||||
:color_output,
|
||||
:preferred_syntax
|
||||
].flatten
|
||||
|
||||
end
|
||||
|
@ -125,6 +125,9 @@ module Compass
|
||||
true
|
||||
end
|
||||
|
||||
def default_preferred_syntax
|
||||
:scss
|
||||
end
|
||||
# helper functions
|
||||
|
||||
def http_join(*segments)
|
||||
|
@ -16,7 +16,7 @@ module Compass
|
||||
self.logger = options[:logger]
|
||||
end
|
||||
|
||||
[:css_dir, :sass_dir, :images_dir, :javascripts_dir, :http_stylesheets_path, :fonts_dir].each do |dir|
|
||||
[:css_dir, :sass_dir, :images_dir, :javascripts_dir, :http_stylesheets_path, :fonts_dir, :preferred_syntax].each do |dir|
|
||||
define_method dir do
|
||||
Compass.configuration.send(dir)
|
||||
end
|
||||
@ -79,6 +79,19 @@ module Compass
|
||||
"#{sass_dir}/#{pattern_name_as_dir}#{to}"
|
||||
end
|
||||
|
||||
def install_stylesheet(from, to, options)
|
||||
from = templatize(from)
|
||||
to = targetize(install_location_for_stylesheet(to, options))
|
||||
contents = File.new(from).read
|
||||
if preferred_syntax.to_s != from[-4..-1]
|
||||
logger.record :convert, basename(from)
|
||||
tree = Sass::Engine.new(contents, Compass.sass_engine_options).to_tree
|
||||
contents = tree.send("to_#{preferred_syntax}")
|
||||
to[-4..-1] = preferred_syntax.to_s
|
||||
end
|
||||
write_file to, contents
|
||||
end
|
||||
|
||||
installer :css do |to|
|
||||
"#{css_dir}/#{to}"
|
||||
end
|
||||
|
@ -7,15 +7,16 @@ module Compass
|
||||
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
||||
|
||||
ACTION_COLORS = {
|
||||
:error => :red,
|
||||
:warning => :yellow,
|
||||
:compile => :green,
|
||||
:error => :red,
|
||||
:warning => :yellow,
|
||||
:compile => :green,
|
||||
:overwrite => :yellow,
|
||||
:create => :green,
|
||||
:remove => :yellow,
|
||||
:exists => :green,
|
||||
:create => :green,
|
||||
:remove => :yellow,
|
||||
:exists => :green,
|
||||
:directory => :green,
|
||||
:identical => :green
|
||||
:identical => :green,
|
||||
:convert => :green
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user