txbr 2.5.1 → 2.5.2
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.
- checksums.yaml +4 -4
- data/lib/txbr/template.rb +18 -4
- data/lib/txbr/version.rb +1 -1
- data/spec/template_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af6782638d9d86f0593f7d1bd4066684dcb447f805e5c324fa1471e8f28bc3bc
|
|
4
|
+
data.tar.gz: 565be3c3aba1c78725433ab38d54bfb6930bd05afb40e385157e14a4233d1855
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2945218cdb7970b015336e857d4cd766ffdbc9bc25459c27bd2c69fc630c3df00368c24c2584bd762f9e50535b4e479738492d5876e42b7c272dc96db4285a52
|
|
7
|
+
data.tar.gz: 6a1cb78704a76414ce698a637e9f80e65577c4d85baa024ea49f22bcea71b15203f048931c91c110c2b7f7253483a57b715e5fd294dd7a64281348f5bf43478d
|
data/lib/txbr/template.rb
CHANGED
|
@@ -69,10 +69,24 @@ module Txbr
|
|
|
69
69
|
# Otherwise, transform the var into something Liquid-friendly so it
|
|
70
70
|
# doesn't jam up the parser.
|
|
71
71
|
def prerender(source, variables)
|
|
72
|
-
source.gsub(/\{\{\s*(?:[\w
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
source.gsub(/\{\s*\{\s*(?:[\w\-\_\.\[\]]+\.)?\$\{\s*[\w\-\.\[\]]+\s*\}?\s*\}?\s*\}?/) do |orig|
|
|
73
|
+
plain = orig.sub(/\A\{\{/, '').sub(/\}\}\z/, '')
|
|
74
|
+
|
|
75
|
+
result = if val = variables[plain]
|
|
76
|
+
"\"#{val}\""
|
|
77
|
+
else
|
|
78
|
+
normalize_braze_var(orig)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if orig.tr(' ', '').start_with?('{{')
|
|
82
|
+
result = "{{#{result}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if orig.tr(' ', '').end_with?('}}')
|
|
86
|
+
result << '}}'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
result
|
|
76
90
|
end
|
|
77
91
|
end
|
|
78
92
|
|
data/lib/txbr/version.rb
CHANGED
data/spec/template_spec.rb
CHANGED
|
@@ -9,6 +9,7 @@ describe Txbr::Template do
|
|
|
9
9
|
<<~SRC
|
|
10
10
|
<h1>Braze campaign is {{campaign.${api_id}}}</h1>
|
|
11
11
|
<h2>Hello, {{${first_name}}}</h2>
|
|
12
|
+
<h3>I speak {{custom_attributes.${preferred_language} | default: 'en'}}</h3>
|
|
12
13
|
SRC
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -24,13 +25,18 @@ describe Txbr::Template do
|
|
|
24
25
|
expect(subject.render).to eq(<<~TEXT)
|
|
25
26
|
<h1>Braze campaign is abc123</h1>
|
|
26
27
|
<h2>Hello, Dwight</h2>
|
|
28
|
+
<h3>I speak en</h3>
|
|
27
29
|
TEXT
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
context 'with no variable replacements' do
|
|
32
34
|
it 'renders without erroring' do
|
|
33
|
-
expect
|
|
35
|
+
expect(subject.render).to eq(<<~TEXT)
|
|
36
|
+
<h1>Braze campaign is </h1>
|
|
37
|
+
<h2>Hello, </h2>
|
|
38
|
+
<h3>I speak en</h3>
|
|
39
|
+
TEXT
|
|
34
40
|
end
|
|
35
41
|
end
|
|
36
42
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: txbr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cameron Dutro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-11-
|
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: abroad
|