Module: Middleman::Extensions::RelativeAssets::InstanceMethods
- Defined in:
- middleman-more/lib/middleman-more/extensions/relative_assets.rb
Overview
Relative Assets instance method
Instance Method Summary (collapse)
-
- (String) asset_url(path, prefix = "")
asset_url override for relative assets.
Instance Method Details
- (String) asset_url(path, prefix = "")
asset_url override for relative assets
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'middleman-more/lib/middleman-more/extensions/relative_assets.rb', line 32 def asset_url(path, prefix="") begin prefix = images_dir if prefix == http_images_path rescue end if path.include?("://") super(path, prefix) elsif path[0,1] == "/" path else path = File.join(prefix, path) if prefix.length > 0 request_path = current_path.dup request_path << index_file if path.match(%r{/$}) parts = request_path.gsub(%r{^/}, '').split('/') if parts.length > 1 arry = [] (parts.length - 1).times { arry << ".." } arry << path File.join(*arry) else path end end end |