Skip to content

Commit

Permalink
Merge pull request #1528 from icco/asset_settings
Browse files Browse the repository at this point in the history
Allow asset_folders to be configured in settings
  • Loading branch information
Ortuna committed Dec 25, 2013
2 parents 5844969 + 4a61c95 commit f458706
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 10 additions & 4 deletions padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb
Expand Up @@ -351,16 +351,22 @@ def asset_timestamp(file_path)
###
# Returns the asset folder given a kind.
#
# Configureable by setting kind_asset_folder.
#
# @example
# asset_folder_name(:css) => 'stylesheets'
# asset_folder_name(:js) => 'javascripts'
# asset_folder_name(:images) => 'images'
#
def asset_folder_name(kind)
case kind
when :css then 'stylesheets'
when :js then 'javascripts'
else kind.to_s
if self.class.respond_to? "#{kind}_asset_folder"
self.class.send "#{kind}_asset_folder"
else
case kind
when :css then 'stylesheets'
when :js then 'javascripts'
else kind.to_s
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions padrino-helpers/test/test_asset_tag_helpers.rb
Expand Up @@ -269,6 +269,14 @@ def flash
assert actual_html.html_safe?
end

should "respond to js_asset_folder setting" do
time = stop_time_for_test
self.class.stubs(:js_asset_folder).returns('js')
assert_equal 'js', asset_folder_name(:js)
actual_html = javascript_include_tag('application')
assert_has_tag('script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
end

should "display javascript item for long relative path" do
time = stop_time_for_test
actual_html = javascript_include_tag('example/demo/application')
Expand Down

0 comments on commit f458706

Please sign in to comment.