Module: Sinatra::AssetPack::HtmlHelpers
- Extended by:
- HtmlHelpers
- Included in:
- HtmlHelpers, Package
- Defined in:
- lib/sinatra/assetpack/html_helpers.rb
Instance Method Summary collapse
Instance Method Details
#e(str) ⇒ Object
6 7 8 9 10 |
# File 'lib/sinatra/assetpack/html_helpers.rb', line 6 def e(str) re = Rack::Utils.escape_html str re = re.gsub("/", '/') # Rack sometimes insists on munging slashes in Ruby 1.8. re end |
#get_file_uri(file, assets) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sinatra/assetpack/html_helpers.rb', line 16 def get_file_uri(file, assets) raise RuntimeError, "You must pass in an asset for a URI to be created for it." if file.nil? local = assets.local_file_for file if assets.asset_hosts.nil? BusterHelpers.add_cache_buster(file, local) else assets.asset_hosts[Digest::MD5.hexdigest(file).to_i(16) % assets.asset_hosts.length]+BusterHelpers.add_cache_buster(file, local) end end |
#kv(hash) ⇒ Object
12 13 14 |
# File 'lib/sinatra/assetpack/html_helpers.rb', line 12 def kv(hash) hash.map { |k, v| " #{e k}='#{e v}'" }.join('') end |