Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/theme_support/helpers/erb_theme_tags.rb
Overview
These are theme helper tags
Instance Method Summary collapse
-
#theme_image_path(source, theme = nil) ⇒ Object
returns the path to a theme image.
-
#theme_image_tag(source, options = {}) ⇒ Object
This tag will return a theme-specific IMG.
-
#theme_javascript_include_tag(*sources) ⇒ Object
This tag can be used to return theme-specific javscripts.
-
#theme_javascript_path(source, theme = nil) ⇒ Object
returns the path to a theme javascript.
-
#theme_stylesheet_link_tag(*sources) ⇒ Object
This tag it will automatially include theme specific css files.
-
#theme_stylesheet_path(source = nil, theme = nil) ⇒ Object
returns the public path to a theme stylesheet.
Instance Method Details
#theme_image_path(source, theme = nil) ⇒ Object
returns the path to a theme image
12 13 14 15 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 12 def theme_image_path( source, theme=nil ) theme = theme || controller.current_theme compute_public_path(source, "themes/#{theme}/images", 'png') end |
#theme_image_tag(source, options = {}) ⇒ Object
This tag will return a theme-specific IMG
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 34 def theme_image_tag(source, = {}) .symbolize_keys [:src] = theme_image_path(source) [:alt] ||= File.basename([:src], '.*').split('.').first.capitalize if [:size] [:width], [:height] = [:size].split("x") .delete :size end tag("img", ) end |
#theme_javascript_include_tag(*sources) ⇒ Object
This tag can be used to return theme-specific javscripts
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 49 def theme_javascript_include_tag(*sources) = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { } if sources.include?(:defaults) sources = sources[0..(sources.index(:defaults))] + @@javascript_default_sources.dup + sources[(sources.index(:defaults) + 1)..sources.length] sources.delete(:defaults) sources << "application" if defined?(Rails.root) && File.exists?("#{Rails.root}/public/javascripts/application.js") end sources.collect { |source| source = theme_javascript_path(source) content_tag("script", "", { "type" => "text/javascript", "src" => source }.merge()) }.join("\n") end |
#theme_javascript_path(source, theme = nil) ⇒ Object
returns the path to a theme javascript
18 19 20 21 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 18 def theme_javascript_path( source, theme=nil ) theme = theme || controller.current_theme compute_public_path(source, "themes/#{theme}/javascripts", 'js') end |
#theme_stylesheet_link_tag(*sources) ⇒ Object
This tag it will automatially include theme specific css files
24 25 26 27 28 29 30 31 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 24 def theme_stylesheet_link_tag(*sources) sources.uniq! = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { } sources.collect { |source| source = theme_stylesheet_path(source) tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source }.merge()) }.join("\n") end |
#theme_stylesheet_path(source = nil, theme = nil) ⇒ Object
returns the public path to a theme stylesheet
6 7 8 9 |
# File 'lib/theme_support/helpers/erb_theme_tags.rb', line 6 def theme_stylesheet_path( source=nil, theme=nil ) theme = theme || controller.current_theme compute_public_path(source || "theme", "themes/#{theme}/stylesheets", 'css') end |