Sha256: f754cb09a2f579734f37e78d10f7c6a61173ac13c0ef636a793b958386cc7840
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 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 => image_path(src) } attrs = attrs.merge(options) "<img#{HtmlHelpers.kv attrs} />" end def image_path(src) file_path = HtmlHelpers.get_file_uri(src, settings.assets) File.join(request.script_name, file_path) 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.environment == :production pack.to_production_html request.script_name, options else pack.to_development_html request.script_name, 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 def assets_expires if settings.assets.expires.nil? expires 86400*30, :public else expires *settings.assets.expires end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-assetpack-0.3.3 | lib/sinatra/assetpack/helpers.rb |
sinatra-assetpack-0.3.2 | lib/sinatra/assetpack/helpers.rb |