txbr 2.5.0 → 2.5.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: 159bfa45f2d0f53ef30fe11e2bd6dfbf1b07b0ea0e19530ca3ac3d171308c4ac
4
- data.tar.gz: 15621955923af3e6aa17933faf75eb344e5be7a8bd34fe52ea526d1f88a01be3
3
+ metadata.gz: 76cd2b1c7f112ffc17ecc1c94b5554a6f317e30052aabb0a8e5c6166cc85c329
4
+ data.tar.gz: be7802bd15965b7123abb22bf3e27fbccfe62660eaac9738c55a8e35cfd24f9e
5
5
  SHA512:
6
- metadata.gz: 7247f257169835737f3d834d8afc0cba5930314e439a3629acfa526b4f3d7197eece08194c3f85a848a17932a3aea22540a9386a79699d286f860c140cd8f9c7
7
- data.tar.gz: 9416bc14041f5b8b261ecad1de0e8aa7ccaf61d3ddc11297cc6d3aa907cf14c029ae9c3e37b45d53325ed8c2bc6e87af44b580189fae59aa5f2cfb3dbddb70fc
6
+ metadata.gz: eb9e39e6d90512286d9f48f83b70cda2bfdcfeebbf4021c970e171a00ca20a7afdd32729c5470c650b31f3fe15b61634f65b162d85a60cab74beaf46ef13657c
7
+ data.tar.gz: 5d97695feea4607cf5746af8ea7f3cb30bd60d3e385104d3ea2d32b8aa67c17271c9af79d35631bc05e52818eb6375979bb581ac256de1772ac50c9c82dbf170
@@ -63,12 +63,13 @@ module Txbr
63
63
  end
64
64
  end
65
65
 
66
- # Designed to replace special Braze variables like {{campaign.${api_id}}},
67
- # which Liquid can't natively handle. If the variable exists in the given
68
- # variables hash, replace it with the value directly. Otherwise, transform
69
- # the var into something Liquid-friendly so it doesn't jam up the parser.
66
+ # Designed to replace special Braze variables like {{campaign.${api_id}}}
67
+ # and ${first_name}, which Liquid can't natively handle. If the variable
68
+ # exists in the given variables hash, replace it with the value directly.
69
+ # Otherwise, transform the var into something Liquid-friendly so it
70
+ # doesn't jam up the parser.
70
71
  def prerender(source, variables)
71
- source.gsub(/\{\{[\w\-\.\[\]]+\.\$\{[\w\-\.\[\]]+\}\}\}/) do |orig|
72
+ source.gsub(/\{\{\s*(?:[\w\-\.\[\]]+\.)?\$\{\s*[\w\-\.\[\]]+\s*\}\s*\}\s*\}/) do |orig|
72
73
  orig = orig[2..-3] # remove curlies
73
74
  next variables[orig] if variables.include?(orig)
74
75
  "{{#{normalize_braze_var(orig)}}}"
@@ -1,3 +1,3 @@
1
1
  module Txbr
2
- VERSION = '2.5.0'
2
+ VERSION = '2.5.1'
3
3
  end
@@ -8,14 +8,23 @@ describe Txbr::Template do
8
8
  let(:source) do
9
9
  <<~SRC
10
10
  <h1>Braze campaign is {{campaign.${api_id}}}</h1>
11
+ <h2>Hello, {{${first_name}}}</h2>
11
12
  SRC
12
13
  end
13
14
 
14
15
  context 'with a direct variable replacement' do
15
- let(:prerender_variables) { { 'campaign.${api_id}' => 'abc123' } }
16
+ let(:prerender_variables) do
17
+ {
18
+ 'campaign.${api_id}' => 'abc123',
19
+ '${first_name}' => 'Dwight'
20
+ }
21
+ end
16
22
 
17
23
  it 'prerenders correctly' do
18
- expect(subject.render.strip).to eq("<h1>Braze campaign is abc123</h1>")
24
+ expect(subject.render).to eq(<<~TEXT)
25
+ <h1>Braze campaign is abc123</h1>
26
+ <h2>Hello, Dwight</h2>
27
+ TEXT
19
28
  end
20
29
  end
21
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro