aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-03 17:03:45 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-03 17:08:10 -0200
commit439d3407eaef1f1b3abc94c766dedac220e59785 (patch)
treeeb0223b6058a3d52c474ab8bb05fd5445ab6cc23 /actionpack/lib/action_view/helpers
parent41be0fc3df4cc080df912ae87bd1c8503f2b348d (diff)
downloadrails-439d3407eaef1f1b3abc94c766dedac220e59785.tar.gz
rails-439d3407eaef1f1b3abc94c766dedac220e59785.tar.bz2
rails-439d3407eaef1f1b3abc94c766dedac220e59785.zip
Add font_path helper method
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 653e12c7d8..5dbba3c4a7 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -306,6 +306,20 @@ module ActionView
end
alias_method :path_to_audio, :audio_path # aliased to avoid conflicts with an audio_path named route
+ # Computes the path to a font asset in the public fonts directory.
+ # Full paths from the document root will be passed through.
+ #
+ # ==== Examples
+ # font_path("font") # => /fonts/font
+ # font_path("font.ttf") # => /fonts/font.ttf
+ # font_path("dir/font.ttf") # => /fonts/dir/font.ttf
+ # font_path("/dir/font.ttf") # => /dir/font.ttf
+ # font_path("http://www.example.com/dir/font.ttf") # => http://www.example.com/dir/font.ttf
+ def font_path(source)
+ asset_paths.compute_public_path(source, 'fonts')
+ end
+ alias_method :path_to_font, :font_path # aliased to avoid conflicts with an font_path named route
+
# Returns an html image tag for the +source+. The +source+ can be a full
# path or a file that exists in your public images directory.
#