To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / c3 / c3b3fde2322bc5fb3fb730ddaf39d1d7a4bf6387.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (1.12 KB)

1
# == Using plugin assets for form tag helpers
2
#
3
# It's as easy to use plugin images for image_submit_tag using Engines as it is for image_tag:
4
#
5
#   <%= image_submit_tag "my_face", :plugin => "my_plugin" %>
6
#
7
# ---
8
#
9
# This module enhances one of the methods from ActionView::Helpers::FormTagHelper:
10
#
11
#  * image_submit_tag
12
#
13
# This method now accepts the key/value pair <tt>:plugin => "plugin_name"</tt>,
14
# which can be used to specify the originating plugin for any assets.
15
#
16
module Engines::RailsExtensions::FormTagHelpers
17
	def self.included(base)
18
		base.class_eval do
19
			alias_method_chain :image_submit_tag, :engine_additions
20
		end
21
	end
22
	
23
	# Adds plugin functionality to Rails' default image_submit_tag method.
24
	def image_submit_tag_with_engine_additions(source, options={})
25
		options.stringify_keys!
26
		if options["plugin"]
27
			source = Engines::RailsExtensions::AssetHelpers.plugin_asset_path(options["plugin"], "images", source)
28
			options.delete("plugin")
29
		end
30
		image_submit_tag_without_engine_additions(source, options)
31
	end
32
end
33

    
34
module ::ActionView::Helpers::FormTagHelper #:nodoc:
35
  include Engines::RailsExtensions::FormTagHelpers
36
end
37