lib/spontaneous/rack/helpers.rb in spontaneous-0.2.0.alpha7 vs lib/spontaneous/rack/helpers.rb in spontaneous-0.2.0.beta1

- old
+ new

@@ -13,25 +13,24 @@ def application_assets @application_assets_compiler ||= Spontaneous::Asset::AppCompiler.new(Spontaneous.gem_dir, Spontaneous.root) end def style_url(style) - style = "#{style}.css" unless style =~ /\.css$/ - if (compiled_asset = application_assets.manifest.assets[style]) - return "#{NAMESPACE}/assets/#{compiled_asset}" - end - # TODO: use the sprockets environment to append a modification time to the non-compiled URL - "#{NAMESPACE}/css/#{style}" + asset_url(style, "css") end def script_url(script) - script = "#{script}.js" unless script =~ /\.js$/ + asset_url(script, "js") + end - if (compiled_asset = application_assets.manifest.assets[script]) + def asset_url(file, type) + file = "#{file}.#{type}" unless file =~ /\.#{type}$/ + + if (compiled_asset = application_assets.manifest.assets[file]) return "#{NAMESPACE}/assets/#{compiled_asset}" end # TODO: use the sprockets environment to append a modification time to the non-compiled URL - "#{NAMESPACE}/js/#{script}" + "#{NAMESPACE}/#{type}/#{file}" end def script_list(scripts) scripts.map do |script| script = "#{script}.js" unless script =~ /\.js$/