module Sinatra module AssetPack module Helpers def css(name, options={}) show_asset_pack :css, name, options end def js(name, options={}) show_asset_pack :js, name, options end def img(src, options={}) attrs = { :src => src }.merge(options) local = settings.assets.local_file_for src if local i = Image.new(local) attrs[:src] = BusterHelpers.add_cache_buster(src, local) if i.dimensions? attrs[:width] ||= i.width attrs[:height] ||= i.height end end "" end def show_asset_pack(type, name, options={}) pack = settings.assets.packages["#{name}.#{type}"] return "" unless pack if 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