i18nliner 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7db05f72a6f74269e7600897f2910d08749e1e8d8a334cbd8678e5ed7fe3640b
4
- data.tar.gz: 3ee6d0d8ed3bb20ed38f7d639d9b2a151c1a3ff1c3c09dc7379a8246fcbc6599
3
+ metadata.gz: 49a54d15655300760797d011db9521a123b23892478badcee8cfab3c7c890e25
4
+ data.tar.gz: 97409ad1106e9ed7c68567038bca41495e204545fce5b605b2b30e591072c399
5
5
  SHA512:
6
- metadata.gz: 59db484754a91d810436e65063f705026bbbfdf042a141ca053d0555616a97e83a89cd59cb9654f7d9243ee28a0f81169d1e82f7697b5f55333ea4f55ec71abd
7
- data.tar.gz: 397e276a16b5fc43603de1abdeb1594ccb3a13ed2709809299f1a68d1b536983a66d37ed5d41684cfeb6eb1e3bda381c8e4e121fb6dbacc0e1903973a3ffc6ce
6
+ metadata.gz: d81cc7123036ef5a7f19224d2400b384f4049bee9be1ea9a99d40b12ea2db8739f547861e93bff7c51f7639c1877c0ae672a850325e85a59817ba678b455d31a
7
+ data.tar.gz: 0b465bc13a850bd61ffdbc2459d698f55719cc5cc5cab1bd55ca8e8bfabba8a12a7214def2c95a0fd682b50d4fd4af03092fd4815702081524f1fe92e468a18c
@@ -18,9 +18,19 @@ module I18nliner
18
18
 
19
19
  wrappers = options.delete(:wrappers) || options.delete(:wrapper)
20
20
  result = super(key, options)
21
+
22
+ # In rails 6.1+ views, sometimes an Object is used for the default, and that object needs to remain
23
+ # an object or it won't be recognized if it comes back as a string
24
+ return result if result.nil? || result.instance_of?(Object)
25
+
26
+ # If you are actually using nonprintable characters in your source string, you should feel ashamed
27
+ result = result.gsub("\\\\", "\uE124").gsub("\\*", "\uE123")
21
28
  if wrappers
22
29
  result = apply_wrappers(result, wrappers)
23
30
  end
31
+ was_html_safe = result.html_safe?
32
+ result = result.gsub("\uE123", '*').gsub("\uE124", "\\")
33
+ result = result.html_safe if was_html_safe
24
34
 
25
35
  result
26
36
  rescue ArgumentError
@@ -53,10 +63,6 @@ module I18nliner
53
63
  private
54
64
 
55
65
  def apply_wrappers(string, wrappers)
56
- # In rails 6.1+ views, sometimes an Object is used for the default, and that object needs to remain
57
- # an object or it won't be recognized if it comes back as a string
58
- return string if string.instance_of?(Object)
59
-
60
66
  string = string.html_safe? ? string.dup : ERB::Util.h(string)
61
67
  unless wrappers.is_a?(Hash)
62
68
  wrappers = Array(wrappers)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-09 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport