Skip to content

Commit cdcec0a

Browse files
committed
Added rewrite_relative_paths.
1 parent bf6afc5 commit cdcec0a

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ <h2 id="configuration">Configuration</h2>
235235
if you're packaging assets in development.
236236
</td>
237237
</tr>
238+
<tr>
239+
<td><b>rewrite_relative_paths</b></td>
240+
<td><tt>on&nbsp;|&nbsp;off</tt></td>
241+
<td class="definition">
242+
Defaults to <b>on</b>. When <b>off</b>, relative paths with CSS will be left unchanged.
243+
</td>
244+
</tr>
238245
<tr>
239246
<td><b>gzip_assets</b></td>
240247
<td><tt>on&nbsp;|&nbsp;off</tt></td>

lib/jammit.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class << self
5252
:embed_assets, :package_assets, :compress_assets, :gzip_assets,
5353
:package_path, :mhtml_enabled, :include_jst_script, :config_path,
5454
:javascript_compressor, :compressor_options, :css_compressor_options,
55-
:template_extension, :template_extension_matcher, :allow_debugging
55+
:template_extension, :template_extension_matcher, :allow_debugging,
56+
:rewrite_relative_paths
5657
attr_accessor :compressors
5758
end
5859

@@ -77,6 +78,7 @@ def self.load_configuration(config_path, soft=false)
7778
@package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
7879
@embed_assets = conf[:embed_assets] || conf[:embed_images]
7980
@compress_assets = !(conf[:compress_assets] == false)
81+
@rewrite_relative_paths = !(conf[:rewrite_relative_paths] == false)
8082
@gzip_assets = !(conf[:gzip_assets] == false)
8183
@allow_debugging = !(conf[:allow_debugging] == false)
8284
@mhtml_enabled = @embed_assets && @embed_assets != "datauri"

lib/jammit/compressor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ def with_mhtml(css, asset_url)
172172
end
173173
[MHTML_START, mhtml, MHTML_END, css].flatten.join('')
174174
end
175-
175+
176176
# Return a rewritten asset URL for a new stylesheet -- the asset should
177177
# be tagged for embedding if embeddable, and referenced at the correct level
178178
# if relative.
179179
def construct_asset_path(asset_path, css_path, variant)
180180
public_path = absolute_path(asset_path, css_path)
181181
return "__EMBED__#{public_path}" if embeddable?(public_path, variant)
182-
source = asset_path.absolute? ? asset_path.to_s : relative_path(public_path)
182+
source = asset_path.absolute? || ! Jammit.rewrite_relative_paths ? asset_path.to_s : relative_path(public_path)
183183
rewrite_asset_path(source, public_path)
184184
end
185185

0 commit comments

Comments
 (0)