Permalink
Browse files

[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.
  • Loading branch information...
chriseppstein committed Jul 4, 2009
1 parent a6bc874 commit 956c437fe9ffaad08b6b34d91b6cfb80d6121a2f
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
View
@@ -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:'
View
@@ -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 = <<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

0 comments on commit 956c437

Please sign in to comment.