diff --git a/examples/blueprint_default/config.rb b/examples/blueprint_default/config.rb index dade73f815..bbb651edcd 100644 --- a/examples/blueprint_default/config.rb +++ b/examples/blueprint_default/config.rb @@ -4,5 +4,4 @@ sass_dir = "src" images_dir = "images" output_style = :compact -# To enable relative image paths using the images_url() function: -http_images_path = :relative +relative_assets = true diff --git a/examples/blueprint_plugins/config.rb b/examples/blueprint_plugins/config.rb index fe37a4895d..16f4235dd1 100644 --- a/examples/blueprint_plugins/config.rb +++ b/examples/blueprint_plugins/config.rb @@ -4,6 +4,5 @@ sass_dir = "src" images_dir = "images" output_style = :compact -# To enable relative image paths using the images_url() function: -# http_images_path = :relative -http_images_path = :relative +relative_assets = true + diff --git a/examples/blueprint_semantic/config.rb b/examples/blueprint_semantic/config.rb index dade73f815..bbb651edcd 100644 --- a/examples/blueprint_semantic/config.rb +++ b/examples/blueprint_semantic/config.rb @@ -4,5 +4,4 @@ sass_dir = "src" images_dir = "images" output_style = :compact -# To enable relative image paths using the images_url() function: -http_images_path = :relative +relative_assets = true diff --git a/examples/compass/config.rb b/examples/compass/config.rb index dade73f815..bbb651edcd 100644 --- a/examples/compass/config.rb +++ b/examples/compass/config.rb @@ -4,5 +4,4 @@ sass_dir = "src" images_dir = "images" output_style = :compact -# To enable relative image paths using the images_url() function: -http_images_path = :relative +relative_assets = true diff --git a/lib/compass/configuration.rb b/lib/compass/configuration.rb index 59da900abf..920893aa08 100644 --- a/lib/compass/configuration.rb +++ b/lib/compass/configuration.rb @@ -13,6 +13,7 @@ class Configuration :javascripts_dir, :output_style, :environment, + :relative_assets, :http_images_path, :additional_import_paths, :sass_options @@ -44,6 +45,7 @@ def parse_string(contents, filename) self.additional_import_paths ||= [] self.additional_import_paths += @added_import_paths end + issue_deprecation_warnings end def set_all(options) @@ -99,6 +101,21 @@ def comment_for_http_images_path "# To enable relative image paths using the images_url() function:\n# http_images_path = :relative\n" end + def relative_assets? + # the http_images_path is deprecated, but here for backwards compatibility. + relative_assets || http_images_path == :relative + end + + def comment_for_relative_assets + unless relative_assets + %q{# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true +} + else + "" + end + end + def default_output_style if environment == :development :expanded @@ -249,6 +266,12 @@ def reset! self.required_libraries = [] end + def issue_deprecation_warnings + if http_images_path == :relative + puts "DEPRECATION WARNING: Please set relative_assets = true to enable relative paths." + end + end + def require(lib) required_libraries << lib super diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index c52b7daf7f..9877e6291a 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -184,6 +184,10 @@ def set_opts(opts) self.options[:output_style] = style end + opts.on('--relative-assets', :NONE, 'Make compass asset helpers generate relative urls to assets.') do + self.options[:relative_assets] = true + end + opts.separator '' opts.separator 'General Options:' diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 5a6f0737a1..5ce3a350f6 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -18,9 +18,8 @@ def test_parse_and_serialize images_dir = "img" javascripts_dir = "js" output_style = :nested - # To enable relative image paths using the images_url() function: - # http_images_path = :relative - http_images_path = "/images" + # To enable relative paths to assets via compass helper functions. Uncomment: + # relative_assets = true CONFIG Compass.configuration.parse_string(contents, "test_parse") @@ -82,8 +81,8 @@ def test_additional_import_paths # Require any additional compass plugins here. project_path = "/home/chris/my_compass_project" css_dir = "css" -# To enable relative image paths using the images_url() function: -# http_images_path = :relative +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true additional_import_paths = ["../foo", "/path/to/my/framework"] EXPECTED assert_equal expected_serialization, Compass.configuration.serialize @@ -101,10 +100,12 @@ def test_sass_options expected_serialization = <"bar"} EXPECTED + assert_equal expected_serialization, Compass.configuration.serialize end