curlybars 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/curlybars/node/item.rb +3 -3
- data/lib/curlybars/node/path.rb +2 -2
- data/lib/curlybars/version.rb +1 -1
- data/spec/integration/node/if_else_spec.rb +31 -0
- data/spec/integration/node/path_spec.rb +14 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fbfe78e305b68cad9c83ab0deafe39a1814b519ede424de8459dfe8f096bee1
|
4
|
+
data.tar.gz: 7fb5ee604e9379a73ef24cd607aea3a847656a3ecc6f3fddbedd0c4031b398fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f3d779a0858270de68a2715f6badb08290cf977ad792ea019ee8d5b6f20ecc837371129d98a97f2a118df2edff352ec41d71023b4789b05321315fac5847526
|
7
|
+
data.tar.gz: baeb86fd6563d5baca979bcc6cdd08f3a3a66b75bc29692fcbf366b7b3518725e2bd1fbdd6afa6b66567d95436f6d2d241c3d4c1cb81c6315a337df0aa9fc0aa
|
data/lib/curlybars/node/item.rb
CHANGED
data/lib/curlybars/node/path.rb
CHANGED
@@ -60,10 +60,10 @@ module Curlybars
|
|
60
60
|
path_split_by_slashes = path.split('/')
|
61
61
|
backward_steps_on_branches = path_split_by_slashes.count - 1
|
62
62
|
base_tree_position = branches.length - backward_steps_on_branches
|
63
|
+
base_tree_index = base_tree_position - 1
|
63
64
|
|
64
|
-
|
65
|
+
raise Curlybars::Error::Validate.new('unallowed_path', "'#{path}' goes out of scope", position) if base_tree_index < 0
|
65
66
|
|
66
|
-
base_tree_index = base_tree_position - 1
|
67
67
|
base_tree = branches[base_tree_index]
|
68
68
|
|
69
69
|
dotted_path_side = path_split_by_slashes.last
|
data/lib/curlybars/version.rb
CHANGED
@@ -137,5 +137,36 @@ describe "{{#if}}...{{else}}...{{/if}}" do
|
|
137
137
|
|
138
138
|
expect(errors).not_to be_empty
|
139
139
|
end
|
140
|
+
|
141
|
+
it "validates errors the nested else_template when out of context" do
|
142
|
+
dependency_tree = { condition: nil }
|
143
|
+
|
144
|
+
source = <<-HBS
|
145
|
+
{{#if ../condition}}
|
146
|
+
{{else}}
|
147
|
+
{{unallowed_ELSE_method}}
|
148
|
+
{{/if}}
|
149
|
+
HBS
|
150
|
+
|
151
|
+
errors = Curlybars.validate(dependency_tree, source)
|
152
|
+
|
153
|
+
expect(errors.count).to eq(2)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "gives all possible errors found in validation" do
|
157
|
+
dependency_tree = { condition: nil }
|
158
|
+
|
159
|
+
source = <<-HBS
|
160
|
+
{{#if ../condition}}
|
161
|
+
{{unallowed_IF_method}}
|
162
|
+
{{else}}
|
163
|
+
{{unallowed_ELSE_method}}
|
164
|
+
{{/if}}
|
165
|
+
HBS
|
166
|
+
|
167
|
+
errors = Curlybars.validate(dependency_tree, source)
|
168
|
+
|
169
|
+
expect(errors.count).to eq(3)
|
170
|
+
end
|
140
171
|
end
|
141
172
|
end
|
@@ -139,7 +139,7 @@ describe "{{path}}" do
|
|
139
139
|
expect(errors).to be_empty
|
140
140
|
end
|
141
141
|
|
142
|
-
it "
|
142
|
+
it "gives errors errors when it goes out of context" do
|
143
143
|
dependency_tree = {}
|
144
144
|
|
145
145
|
source = <<-HBS
|
@@ -148,7 +148,7 @@ describe "{{path}}" do
|
|
148
148
|
|
149
149
|
errors = Curlybars.validate(dependency_tree, source)
|
150
150
|
|
151
|
-
expect(errors).
|
151
|
+
expect(errors).not_to be_empty
|
152
152
|
end
|
153
153
|
|
154
154
|
it "without errors using `this`" do
|
@@ -257,6 +257,18 @@ describe "{{path}}" do
|
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
260
|
+
it "with errors when going outside of scope" do
|
261
|
+
dependency_tree = { ok: { ok: { ok: nil } } }
|
262
|
+
|
263
|
+
source = <<~HBS
|
264
|
+
{{../ok.ok.ok}}
|
265
|
+
HBS
|
266
|
+
|
267
|
+
errors = Curlybars.validate(dependency_tree, source)
|
268
|
+
|
269
|
+
expect(errors.first.message).to eq("'../ok.ok.ok' goes out of scope")
|
270
|
+
end
|
271
|
+
|
260
272
|
describe "raises exact location of unallowed steps" do
|
261
273
|
let(:dependency_tree) { { ok: { allowed: { ok: nil } } } }
|
262
274
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curlybars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Libo Cannici
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-
|
16
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: actionpack
|
@@ -292,8 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
292
|
- !ruby/object:Gem::Version
|
293
293
|
version: '0'
|
294
294
|
requirements: []
|
295
|
-
|
296
|
-
rubygems_version: 2.7.6
|
295
|
+
rubygems_version: 3.0.6
|
297
296
|
signing_key:
|
298
297
|
specification_version: 4
|
299
298
|
summary: Create your views using Handlebars templates!
|