Sha256: c87de24c6d4780878b5b9f83d4925e633077f04b8d9063eeafea769b11750f54
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
module Provideal module PluginUtils module AssetTagHelper 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 def stylesheet_link_tag_with_plugin_support(*sources) stylesheet_link_tag_without_plugin_support(*Provideal::PluginUtils::AssetTagHelper.pluginify_sources("stylesheets", *sources)) end def javascript_include_tag_with_plugin_support(*sources) javascript_include_tag_without_plugin_support(*Provideal::PluginUtils::AssetTagHelper.pluginify_sources("javascripts", *sources)) end def image_path_with_plugin_support(source, options = {}) options.stringify_keys! pluginified_source = Provideal::PluginUtils::AssetTagHelper.plugin_asset_path(options["plugin"], "images", source) if options["plugin"] image_path_without_plugin_support(pluginified_source) end def image_tag_with_plugin_support(source, options = {}) options.stringify_keys! if options["plugin"] pluginified_source = Provideal::PluginUtils::AssetTagHelper.plugin_asset_path(options["plugin"], "images", source) options.delete("plugin") end image_tag_without_plugin_support(pluginified_source, options) end def self.pluginify_sources(type, *sources) options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { } if options["plugin"] sources.map! { |s| plugin_asset_path(options["plugin"], type, s) } options.delete("plugin") end sources << options end def self.plugin_asset_path(plugin_name, type, asset) "/plugins/#{plugin_name}/#{type}/#{asset}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
provideal-plugin-utils-0.1.1 | lib/provideal_plugin_utils/asset_tag_helper.rb |
provideal-plugin-utils-0.1.0 | lib/provideal_plugin_utils/asset_tag_helper.rb |