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]
|
self.options[:pattern] = framework[1]
|
||||||
end
|
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
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,6 +16,10 @@ Example:
|
|||||||
|
|
||||||
Options:
|
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
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,8 @@ module Compass
|
|||||||
:asset_host,
|
:asset_host,
|
||||||
:asset_cache_buster,
|
:asset_cache_buster,
|
||||||
:line_comments,
|
:line_comments,
|
||||||
:color_output
|
:color_output,
|
||||||
|
:preferred_syntax
|
||||||
].flatten
|
].flatten
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -125,6 +125,9 @@ module Compass
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def default_preferred_syntax
|
||||||
|
:scss
|
||||||
|
end
|
||||||
# helper functions
|
# helper functions
|
||||||
|
|
||||||
def http_join(*segments)
|
def http_join(*segments)
|
||||||
|
@ -16,7 +16,7 @@ module Compass
|
|||||||
self.logger = options[:logger]
|
self.logger = options[:logger]
|
||||||
end
|
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
|
define_method dir do
|
||||||
Compass.configuration.send(dir)
|
Compass.configuration.send(dir)
|
||||||
end
|
end
|
||||||
@ -79,6 +79,19 @@ module Compass
|
|||||||
"#{sass_dir}/#{pattern_name_as_dir}#{to}"
|
"#{sass_dir}/#{pattern_name_as_dir}#{to}"
|
||||||
end
|
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|
|
installer :css do |to|
|
||||||
"#{css_dir}/#{to}"
|
"#{css_dir}/#{to}"
|
||||||
end
|
end
|
||||||
|
@ -7,15 +7,16 @@ module Compass
|
|||||||
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
||||||
|
|
||||||
ACTION_COLORS = {
|
ACTION_COLORS = {
|
||||||
:error => :red,
|
:error => :red,
|
||||||
:warning => :yellow,
|
:warning => :yellow,
|
||||||
:compile => :green,
|
:compile => :green,
|
||||||
:overwrite => :yellow,
|
:overwrite => :yellow,
|
||||||
:create => :green,
|
:create => :green,
|
||||||
:remove => :yellow,
|
:remove => :yellow,
|
||||||
:exists => :green,
|
:exists => :green,
|
||||||
:directory => :green,
|
:directory => :green,
|
||||||
:identical => :green
|
:identical => :green,
|
||||||
|
:convert => :green
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user