handlebars-helpers 0.0.79 → 0.0.80
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39509c73f11207c3e1d83f13c505597b78e5a168d724e5d71295f95d1ec48fbc
|
4
|
+
data.tar.gz: 7e185664a22428731c2512b6a576d82784ae0f16f218fe22b34117639f7475aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b285b313b078c81cbd76e5b68fb43c6c7ed2f0c81e39dd3b18adb623d4629ab7396cf2a068cc51fe3380c5a26a4cd85856fd1ba81ae6692409a3add7699cabac
|
7
|
+
data.tar.gz: 7b89009b0db7dae0e635fa09d0f7b362bd15b17850db9548a07b891784bb11f0f3fcd6da703347d82473f27187ff8c765c7a491d783283c64ce3eb79ad41bb70
|
@@ -21,22 +21,29 @@ module Handlebars
|
|
21
21
|
#
|
22
22
|
# @param [Object] value - object to be converted to Javascript notation string
|
23
23
|
# @return [String] value as Javascript string
|
24
|
-
def parse(value)
|
24
|
+
def parse(value, format)
|
25
25
|
return '' if value.nil?
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
format = :include_root_brace if format.nil?
|
28
|
+
|
29
|
+
javascript = case value
|
30
|
+
when Hash
|
31
|
+
hash_to_javascript(value)
|
32
|
+
when OpenStruct, V8::Object, V8::Array
|
33
|
+
hash_to_javascript(parse_json(value))
|
34
|
+
end
|
35
|
+
|
36
|
+
javascript = remove_root_brace(javascript) if format == :exclude_root
|
37
|
+
javascript
|
33
38
|
end
|
34
39
|
|
35
40
|
def handlebars_helper
|
36
|
-
proc do |_context, value|
|
41
|
+
proc do |_context, value, format|
|
42
|
+
# Handle optional: format
|
43
|
+
format = nil if format.is_a?(V8::Object)
|
37
44
|
# Handle optional: value
|
38
45
|
# value = nil if value.is_a?(V8::Object)
|
39
|
-
wrapper(parse(value))
|
46
|
+
wrapper(parse(value, format))
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
@@ -55,6 +62,10 @@ module Handlebars
|
|
55
62
|
"#{$LAST_MATCH_INFO['name']}:"
|
56
63
|
end
|
57
64
|
end
|
65
|
+
|
66
|
+
def remove_root_brace(javascript)
|
67
|
+
javascript.sub('{', '').tap { |s| s.slice!(s.rindex('}')) }.strip
|
68
|
+
end
|
58
69
|
end
|
59
70
|
end
|
60
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handlebars-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|