[Configuration] [Command Line] Whether to generate relative links to assets is now controlled by a separate configuration flag and can be set via a command-line switch.
This commit is contained in:
parent
a6bc874cf6
commit
956c437fe9
@ -4,5 +4,4 @@ css_dir = "stylesheets"
|
||||
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
|
||||
|
@ -4,6 +4,5 @@ css_dir = "stylesheets"
|
||||
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
|
||||
|
||||
|
@ -4,5 +4,4 @@ css_dir = "stylesheets"
|
||||
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
|
||||
|
@ -4,5 +4,4 @@ css_dir = "stylesheets"
|
||||
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
|
||||
|
@ -13,6 +13,7 @@ module Compass
|
||||
:javascripts_dir,
|
||||
:output_style,
|
||||
:environment,
|
||||
:relative_assets,
|
||||
:http_images_path,
|
||||
:additional_import_paths,
|
||||
:sass_options
|
||||
@ -44,6 +45,7 @@ module Compass
|
||||
self.additional_import_paths ||= []
|
||||
self.additional_import_paths += @added_import_paths
|
||||
end
|
||||
issue_deprecation_warnings
|
||||
end
|
||||
|
||||
def set_all(options)
|
||||
@ -99,6 +101,21 @@ module Compass
|
||||
"# 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 @@ module Compass
|
||||
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
|
||||
|
@ -184,6 +184,10 @@ END
|
||||
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:'
|
||||
|
||||
|
@ -18,9 +18,8 @@ class ConfigurationTest < Test::Unit::TestCase
|
||||
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 @@ class ConfigurationTest < Test::Unit::TestCase
|
||||
# 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 @@ EXPECTED
|
||||
|
||||
expected_serialization = <<EXPECTED
|
||||
# Require any additional compass plugins here.
|
||||
# To enable relative image paths using the images_url() function:
|
||||
# http_images_path = :relative
|
||||
# Set this to the root of your project when deployed:
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
sass_options = {:foo=>"bar"}
|
||||
EXPECTED
|
||||
|
||||
assert_equal expected_serialization, Compass.configuration.serialize
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user