bootstrap_flash_messages 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -22,6 +22,10 @@ And that's it!
|
|
22
22
|
|
23
23
|
## Changes
|
24
24
|
|
25
|
+
Version 0.0.3 changes (14/08/2012):
|
26
|
+
|
27
|
+
- Added interpolation to the flash messages
|
28
|
+
|
25
29
|
Version 0.0.2 changes (10/08/2012):
|
26
30
|
|
27
31
|
- Changed the 'x' in close to & t i m e s ;
|
@@ -107,6 +111,19 @@ Want a heading? Add `:heading`. The headings inside flash.en.yml are used for th
|
|
107
111
|
|
108
112
|
And that's it! Have fun. :)
|
109
113
|
|
114
|
+
## Interpolation
|
115
|
+
|
116
|
+
You can use i18n interpolation like this:
|
117
|
+
|
118
|
+
redirect_to :root, :flash => [:success, :info], :locals => { :name => @user.name, :email => @user.email }
|
119
|
+
flash! :success, :info, :locals => { :name => @user.name, :email => @user.email }
|
120
|
+
flash_now! :success, :info, :locals => { :name => @user.name, :email => @user.email }
|
121
|
+
|
122
|
+
Inside `flash.en.yml` you can do the following:
|
123
|
+
|
124
|
+
success: "Welcome, %{name}."
|
125
|
+
info: "Your e-mail address has been changed to: %{email}."
|
126
|
+
|
110
127
|
|
111
128
|
## Why I created this gem
|
112
129
|
|
@@ -4,13 +4,15 @@ module BootstrapFlashMessages
|
|
4
4
|
messages = response_status_and_flash[:flash]
|
5
5
|
if messages && (messages.is_a?(Symbol) || messages.is_a?(Array))
|
6
6
|
flashes = {}
|
7
|
+
key_options = response_status_and_flash[:locals]
|
7
8
|
if messages.is_a?(Array)
|
8
9
|
messages.each do |key|
|
9
|
-
flashes[key] = flash_messages(params[:controller], params[:action], key)
|
10
|
+
flashes[key] = flash_messages(params[:controller], params[:action], key, key_options)
|
10
11
|
end
|
11
12
|
else
|
12
|
-
flashes[messages] = flash_messages(params[:controller], params[:action], messages)
|
13
|
+
flashes[messages] = flash_messages(params[:controller], params[:action], messages, key_options)
|
13
14
|
end
|
15
|
+
response_status_and_flash.delete(:locals)
|
14
16
|
response_status_and_flash[:flash] = flashes
|
15
17
|
end
|
16
18
|
super(options, response_status_and_flash)
|
@@ -19,19 +21,23 @@ module BootstrapFlashMessages
|
|
19
21
|
private
|
20
22
|
|
21
23
|
def flash!(*args)
|
24
|
+
options = args.extract_options!
|
22
25
|
args.each do |key|
|
23
|
-
flash[key] = flash_messages(params[:controller], params[:action], key)
|
26
|
+
flash[key] = flash_messages(params[:controller], params[:action], key, options[:locals])
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
def flash_now!(*args)
|
31
|
+
options = args.extract_options!
|
28
32
|
args.each do |key|
|
29
|
-
|
33
|
+
key_options = options[:interpolation][key] if options.has_key?(:interpolation)
|
34
|
+
flash.now[key] = flash_messages(params[:controller], params[:action], key, options[:locals])
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
33
38
|
def flash_messages(*args)
|
34
|
-
|
39
|
+
options = args.extract_options!
|
40
|
+
I18n.t("flash_messages.#{args.join(".")}", options)
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_flash_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robin Brouwer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-08-
|
18
|
+
date: 2012-08-14 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|