Module: Provideal::PluginUtils::AssetTagHelper
- Defined in:
- lib/provideal_plugin_utils/asset_tag_helper.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
- .plugin_asset_path(plugin_name, type, asset) ⇒ Object
- .pluginify_sources(type, *sources) ⇒ Object
Instance Method Summary collapse
- #image_path_with_plugin_support(source, options = {}) ⇒ Object
- #image_tag_with_plugin_support(source, options = {}) ⇒ Object
- #javascript_include_tag_with_plugin_support(*sources) ⇒ Object
- #stylesheet_link_tag_with_plugin_support(*sources) ⇒ Object
Class Method Details
.included(base) ⇒ Object
:nodoc:
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 5 def self.included(base) #:nodoc: base.class_eval do [ :stylesheet_link_tag, :javascript_include_tag, :image_path, :image_tag ].each do |m| alias_method_chain m, :plugin_support end end end |
.plugin_asset_path(plugin_name, type, asset) ⇒ Object
52 53 54 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 52 def self.plugin_asset_path(plugin_name, type, asset) "/plugins/#{plugin_name}/#{type}/#{asset}" end |
.pluginify_sources(type, *sources) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 43 def self.pluginify_sources(type, *sources) = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { } if ["plugin"] sources.map! { |s| plugin_asset_path(["plugin"], type, s) } .delete("plugin") end sources << end |
Instance Method Details
#image_path_with_plugin_support(source, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 26 def image_path_with_plugin_support(source, = {}) .stringify_keys! pluginified_source = Provideal::PluginUtils::AssetTagHelper.plugin_asset_path(["plugin"], "images", source) if ["plugin"] image_path_without_plugin_support(pluginified_source) end |
#image_tag_with_plugin_support(source, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 32 def image_tag_with_plugin_support(source, = {}) .stringify_keys! if ["plugin"] pluginified_source = Provideal::PluginUtils::AssetTagHelper.plugin_asset_path(["plugin"], "images", source) .delete("plugin") image_tag_without_plugin_support(pluginified_source, ) else image_tag_without_plugin_support(source, ) end end |
#javascript_include_tag_with_plugin_support(*sources) ⇒ Object
22 23 24 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 22 def javascript_include_tag_with_plugin_support(*sources) javascript_include_tag_without_plugin_support(*Provideal::PluginUtils::AssetTagHelper.pluginify_sources("javascripts", *sources)) end |
#stylesheet_link_tag_with_plugin_support(*sources) ⇒ Object
18 19 20 |
# File 'lib/provideal_plugin_utils/asset_tag_helper.rb', line 18 def stylesheet_link_tag_with_plugin_support(*sources) stylesheet_link_tag_without_plugin_support(*Provideal::PluginUtils::AssetTagHelper.pluginify_sources("stylesheets", *sources)) end |