File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 4
4
module I18n
5
5
DEFAULT_INTERPOLATION_PATTERNS = [
6
6
/%%/ ,
7
- /%\{ (\w +)\} / , # matches placeholders like "%{foo}"
7
+ /%\{ ([ \w |] +)\} / , # matches placeholders like "%{foo} or %{foo|word }"
8
8
/%<(\w +)>(.*?\d *\. ?\d *[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
9
9
] . freeze
10
10
INTERPOLATION_PATTERN = Regexp . union ( DEFAULT_INTERPOLATION_PATTERNS )
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ module Interpolation
24
24
assert_equal 'Hi David!' , interpolate ( :default => 'Hi %{name}!' , :name => 'David' )
25
25
end
26
26
27
+ test "interpolation: works with a pipe" do
28
+ assert_equal 'Hi david!' , interpolate ( :default => 'Hi %{name|lowercase}!' , :'name|lowercase' => 'david' )
29
+ end
30
+
27
31
test "interpolation: given a nil value it still interpolates it into the string" do
28
32
assert_equal 'Hi !' , interpolate ( :default => 'Hi %{name}!' , :name => nil )
29
33
end
You can’t perform that action at this time.
0 commit comments