lib/sinatra/assetpack/helpers.rb in sinatra-assetpack-0.0.5 vs lib/sinatra/assetpack/helpers.rb in sinatra-assetpack-0.0.6

- old
+ new

@@ -1,14 +1,14 @@ module Sinatra module AssetPack module Helpers - def css(name, options={}) - show_asset_pack :css, name, options + def css(*args) + show_asset_pack :css, *args end - def js(name, options={}) - show_asset_pack :js, name, options + def js(*args) + show_asset_pack :js, *args end def img(src, options={}) attrs = { :src => src }.merge(options) @@ -23,10 +23,23 @@ end "<img#{HtmlHelpers.kv attrs} />" end - def show_asset_pack(type, name, options={}) + 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.production? pack.to_production_html options