diff --git a/lib/compass/commands/create_project.rb b/lib/compass/commands/create_project.rb index fa3d2dbe..621da66a 100644 --- a/lib/compass/commands/create_project.rb +++ b/lib/compass/commands/create_project.rb @@ -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 diff --git a/lib/compass/commands/stamp_pattern.rb b/lib/compass/commands/stamp_pattern.rb index 97199a3c..0af1acf3 100644 --- a/lib/compass/commands/stamp_pattern.rb +++ b/lib/compass/commands/stamp_pattern.rb @@ -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 diff --git a/lib/compass/configuration.rb b/lib/compass/configuration.rb index c6ca3e6a..e3d28978 100644 --- a/lib/compass/configuration.rb +++ b/lib/compass/configuration.rb @@ -35,7 +35,8 @@ module Compass :asset_host, :asset_cache_buster, :line_comments, - :color_output + :color_output, + :preferred_syntax ].flatten end diff --git a/lib/compass/configuration/defaults.rb b/lib/compass/configuration/defaults.rb index 483276da..73e54da7 100644 --- a/lib/compass/configuration/defaults.rb +++ b/lib/compass/configuration/defaults.rb @@ -125,6 +125,9 @@ module Compass true end + def default_preferred_syntax + :scss + end # helper functions def http_join(*segments) diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index 28a2435f..0904b47d 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -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 diff --git a/lib/compass/logger.rb b/lib/compass/logger.rb index bd6c97a1..5d77295d 100644 --- a/lib/compass/logger.rb +++ b/lib/compass/logger.rb @@ -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 }