Sha256: 9fd1bea8d4d965132c3548784f243090345652b137e4967425ca4a0d1e278744
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
module Sinatra module AssetPack module Helpers def css(*args) show_asset_pack :css, *args end def js(*args) show_asset_pack :js, *args end def img(src, options={}) attrs = { :src => src }.merge(options) local = settings.assets.local_file_for src if local i = Image[local] attrs[:src] = BusterHelpers.add_cache_buster(src, local) if i.dimensions? attrs[:width] ||= i.width attrs[:height] ||= i.height end end "<img#{HtmlHelpers.kv attrs} />" end def show_asset_pack(type, *args) names = Array.new while args.first.is_a?(Symbol) names << args.shift end options = args.shift if args.first.is_a?(Hash) names.map { |name| show_one_asset_pack type, name, (options || Hash.new) }.join "\n" end def show_one_asset_pack(type, name, options={}) pack = settings.assets.packages["#{name}.#{type}"] return "" unless pack if (settings.respond_to? 'compressed_env') ? settings.compressed_env : settings.production? pack.to_production_html options else pack.to_development_html options end end def asset_filter_css(str) Css.preproc str, settings.assets end def asset_path_for(file, from) settings.assets.dyn_local_file_for file, from end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-assetpack-flexible-compression-0.0.1 | lib/sinatra/assetpack/helpers.rb |