mvz-ruby-handlebars 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +88 -8
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +4 -4
- data/lib/ruby-handlebars/context.rb +1 -1
- data/lib/ruby-handlebars/escapers/html_escaper.rb +1 -1
- data/lib/ruby-handlebars/helper.rb +1 -1
- data/lib/ruby-handlebars/helpers/each_helper.rb +3 -3
- data/lib/ruby-handlebars/helpers/helper_missing_helper.rb +2 -2
- data/lib/ruby-handlebars/helpers/if_helper.rb +2 -2
- data/lib/ruby-handlebars/helpers/register_default_helpers.rb +5 -5
- data/lib/ruby-handlebars/helpers/unless_helper.rb +2 -2
- data/lib/ruby-handlebars/helpers/with_helper.rb +2 -2
- data/lib/ruby-handlebars/parser.rb +19 -21
- data/lib/ruby-handlebars/template.rb +1 -1
- data/lib/ruby-handlebars/tree.rb +3 -3
- data/lib/ruby-handlebars/version.rb +1 -1
- data/lib/ruby-handlebars.rb +8 -8
- data/spec/handlebars_spec.rb +102 -102
- data/spec/parser_spec.rb +163 -155
- data/spec/ruby-handlebars/context_spec.rb +64 -64
- data/spec/ruby-handlebars/helpers/each_helper_spec.rb +41 -41
- data/spec/ruby-handlebars/helpers/helper_missing_helper_spec.rb +14 -14
- data/spec/ruby-handlebars/helpers/if_helper_spec.rb +16 -16
- data/spec/ruby-handlebars/helpers/register_default_helpers_spec.rb +10 -10
- data/spec/ruby-handlebars/helpers/unless_helper_spec.rb +14 -14
- data/spec/ruby-handlebars/helpers/with_helper_spec.rb +6 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/tree_spec.rb +3 -3
- metadata +18 -4
data/spec/parser_spec.rb
CHANGED
@@ -1,214 +1,214 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative "spec_helper"
|
2
|
+
require_relative "../lib/ruby-handlebars/parser"
|
3
3
|
|
4
4
|
describe Handlebars::Parser do
|
5
5
|
let(:parser) {Handlebars::Parser.new}
|
6
6
|
|
7
|
-
context
|
8
|
-
it
|
9
|
-
expect(parser.parse(
|
7
|
+
context "recognizes" do
|
8
|
+
it "simple templates" do
|
9
|
+
expect(parser.parse("Ho hi !")).to eq({
|
10
10
|
block_items: [
|
11
|
-
{template_content:
|
11
|
+
{template_content: "Ho hi !"}
|
12
12
|
]
|
13
13
|
})
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
expect(parser.parse(
|
16
|
+
it "simple replacements" do
|
17
|
+
expect(parser.parse("{{plic}}")).to eq({
|
18
18
|
block_items: [
|
19
|
-
{replaced_unsafe_item:
|
19
|
+
{replaced_unsafe_item: "plic"}
|
20
20
|
]
|
21
21
|
})
|
22
22
|
|
23
|
-
expect(parser.parse(
|
23
|
+
expect(parser.parse("{{ plic}}")).to eq({
|
24
24
|
block_items: [
|
25
|
-
{replaced_unsafe_item:
|
25
|
+
{replaced_unsafe_item: "plic"}
|
26
26
|
]
|
27
27
|
})
|
28
28
|
|
29
|
-
expect(parser.parse(
|
29
|
+
expect(parser.parse("{{plic }}")).to eq({
|
30
30
|
block_items: [
|
31
|
-
{replaced_unsafe_item:
|
31
|
+
{replaced_unsafe_item: "plic"}
|
32
32
|
]
|
33
33
|
})
|
34
34
|
|
35
|
-
expect(parser.parse(
|
35
|
+
expect(parser.parse("{{ plic }}")).to eq({
|
36
36
|
block_items: [
|
37
|
-
{replaced_unsafe_item:
|
37
|
+
{replaced_unsafe_item: "plic"}
|
38
38
|
]
|
39
39
|
})
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(parser.parse(
|
42
|
+
it "special variables" do
|
43
|
+
expect(parser.parse("{{@first}}")).to eq({
|
44
44
|
block_items: [
|
45
|
-
{replaced_unsafe_item:
|
45
|
+
{replaced_unsafe_item: "@first"}
|
46
46
|
]
|
47
47
|
})
|
48
|
-
expect(parser.parse(
|
48
|
+
expect(parser.parse("{{@last}}")).to eq({
|
49
49
|
block_items: [
|
50
|
-
{replaced_unsafe_item:
|
50
|
+
{replaced_unsafe_item: "@last"}
|
51
51
|
]
|
52
52
|
})
|
53
|
-
expect(parser.parse(
|
53
|
+
expect(parser.parse("{{@index}}")).to eq({
|
54
54
|
block_items: [
|
55
|
-
{replaced_unsafe_item:
|
55
|
+
{replaced_unsafe_item: "@index"}
|
56
56
|
]
|
57
57
|
})
|
58
58
|
end
|
59
59
|
|
60
|
-
it
|
61
|
-
expect(parser.parse(
|
60
|
+
it "safe strings" do
|
61
|
+
expect(parser.parse("{{{plic}}}")).to eq({
|
62
62
|
block_items: [
|
63
|
-
{replaced_safe_item:
|
63
|
+
{replaced_safe_item: "plic"}
|
64
64
|
]
|
65
65
|
})
|
66
66
|
|
67
|
-
expect(parser.parse(
|
67
|
+
expect(parser.parse("{{{ plic}}}")).to eq({
|
68
68
|
block_items: [
|
69
|
-
{replaced_safe_item:
|
69
|
+
{replaced_safe_item: "plic"}
|
70
70
|
]
|
71
71
|
})
|
72
72
|
|
73
|
-
expect(parser.parse(
|
73
|
+
expect(parser.parse("{{{plic }}}")).to eq({
|
74
74
|
block_items: [
|
75
|
-
{replaced_safe_item:
|
75
|
+
{replaced_safe_item: "plic"}
|
76
76
|
]
|
77
77
|
})
|
78
78
|
|
79
|
-
expect(parser.parse(
|
79
|
+
expect(parser.parse("{{{ plic }}}")).to eq({
|
80
80
|
block_items: [
|
81
|
-
{replaced_safe_item:
|
81
|
+
{replaced_safe_item: "plic"}
|
82
82
|
]
|
83
83
|
})
|
84
84
|
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
88
|
-
it
|
89
|
-
expect(parser.parse(
|
87
|
+
context "helpers" do
|
88
|
+
it "simple" do
|
89
|
+
expect(parser.parse("{{ capitalize plic }}")).to eq({
|
90
90
|
block_items: [
|
91
91
|
{
|
92
|
-
unsafe_helper_name:
|
93
|
-
parameters: {parameter_name:
|
92
|
+
unsafe_helper_name: "capitalize",
|
93
|
+
parameters: {parameter_name: "plic"}
|
94
94
|
}
|
95
95
|
]
|
96
96
|
})
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
99
|
+
it "with single-quoted string parameter" do
|
100
100
|
expect(parser.parse("{{ capitalize 'hi'}}")).to eq({
|
101
101
|
block_items: [
|
102
102
|
{
|
103
|
-
unsafe_helper_name:
|
104
|
-
parameters: {parameter_name: {str_content:
|
103
|
+
unsafe_helper_name: "capitalize",
|
104
|
+
parameters: {parameter_name: {str_content: "hi"}},
|
105
105
|
}
|
106
106
|
]
|
107
107
|
})
|
108
108
|
end
|
109
109
|
|
110
|
-
it
|
110
|
+
it "with single-quoted empty string parameter" do
|
111
111
|
expect(parser.parse("{{ capitalize ''}}")).to eq({
|
112
112
|
block_items: [
|
113
113
|
{
|
114
|
-
unsafe_helper_name:
|
115
|
-
parameters: {parameter_name: {str_content:
|
114
|
+
unsafe_helper_name: "capitalize",
|
115
|
+
parameters: {parameter_name: {str_content: ""}},
|
116
116
|
}
|
117
117
|
]
|
118
118
|
})
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
121
|
+
it "with double-quoted string parameter" do
|
122
122
|
expect(parser.parse('{{ capitalize "hi"}}')).to eq({
|
123
123
|
block_items: [
|
124
124
|
{
|
125
|
-
unsafe_helper_name:
|
126
|
-
parameters: {parameter_name: {str_content:
|
125
|
+
unsafe_helper_name: "capitalize",
|
126
|
+
parameters: {parameter_name: {str_content: "hi"}},
|
127
127
|
}
|
128
128
|
]
|
129
129
|
})
|
130
130
|
end
|
131
131
|
|
132
|
-
it
|
132
|
+
it "with double-quoted empty string parameter" do
|
133
133
|
expect(parser.parse('{{ capitalize ""}}')).to eq({
|
134
134
|
block_items: [
|
135
135
|
{
|
136
|
-
unsafe_helper_name:
|
137
|
-
parameters: {parameter_name: {str_content:
|
136
|
+
unsafe_helper_name: "capitalize",
|
137
|
+
parameters: {parameter_name: {str_content: ""}},
|
138
138
|
}
|
139
139
|
]
|
140
140
|
})
|
141
141
|
end
|
142
142
|
|
143
|
-
it
|
144
|
-
expect(parser.parse(
|
143
|
+
it "with multiple parameters" do
|
144
|
+
expect(parser.parse("{{ concat plic ploc plouf }}")).to eq({
|
145
145
|
block_items: [
|
146
146
|
{
|
147
|
-
unsafe_helper_name:
|
147
|
+
unsafe_helper_name: "concat",
|
148
148
|
parameters: [
|
149
|
-
{parameter_name:
|
150
|
-
{parameter_name:
|
151
|
-
{parameter_name:
|
149
|
+
{parameter_name: "plic"},
|
150
|
+
{parameter_name: "ploc"},
|
151
|
+
{parameter_name: "plouf"}
|
152
152
|
]
|
153
153
|
}
|
154
154
|
]
|
155
155
|
})
|
156
156
|
end
|
157
157
|
|
158
|
-
it
|
159
|
-
expect(parser.parse(
|
158
|
+
it "block" do
|
159
|
+
expect(parser.parse("{{#capitalize}}plic{{/capitalize}}")).to eq({
|
160
160
|
block_items: [
|
161
161
|
{
|
162
|
-
helper_name:
|
162
|
+
helper_name: "capitalize",
|
163
163
|
block_items: [
|
164
|
-
{template_content:
|
164
|
+
{template_content: "plic"}
|
165
165
|
]
|
166
166
|
}
|
167
167
|
]
|
168
168
|
})
|
169
169
|
end
|
170
170
|
|
171
|
-
it
|
171
|
+
it "block with parameters" do
|
172
172
|
expect(parser.parse('{{#comment "#"}}plic{{/comment}}')).to eq({
|
173
173
|
block_items: [
|
174
174
|
{
|
175
|
-
helper_name:
|
176
|
-
parameters: {parameter_name: {str_content:
|
175
|
+
helper_name: "comment",
|
176
|
+
parameters: {parameter_name: {str_content: "#"}},
|
177
177
|
block_items: [
|
178
|
-
{template_content:
|
178
|
+
{template_content: "plic"}
|
179
179
|
]
|
180
180
|
}
|
181
181
|
]
|
182
182
|
})
|
183
183
|
end
|
184
184
|
|
185
|
-
it
|
185
|
+
it "imbricated blocks" do
|
186
186
|
expect(parser.parse('{{#comment "#"}}plic {{#capitalize}}ploc{{/capitalize}} plouc{{/comment}}')).to eq({
|
187
187
|
block_items: [
|
188
188
|
{
|
189
|
-
helper_name:
|
190
|
-
parameters: {parameter_name: {str_content:
|
189
|
+
helper_name: "comment",
|
190
|
+
parameters: {parameter_name: {str_content: "#"}},
|
191
191
|
block_items: [
|
192
|
-
{template_content:
|
192
|
+
{template_content: "plic "},
|
193
193
|
{
|
194
|
-
helper_name:
|
195
|
-
block_items: [{template_content:
|
194
|
+
helper_name: "capitalize",
|
195
|
+
block_items: [{template_content: "ploc"}]
|
196
196
|
},
|
197
|
-
{template_content:
|
197
|
+
{template_content: " plouc"},
|
198
198
|
]
|
199
199
|
}
|
200
200
|
]
|
201
201
|
})
|
202
202
|
end
|
203
203
|
|
204
|
-
it
|
205
|
-
expect(parser.parse(
|
204
|
+
it "helpers as arguments" do
|
205
|
+
expect(parser.parse("{{foo (bar baz)}}")).to eq({
|
206
206
|
block_items: [
|
207
207
|
{
|
208
|
-
unsafe_helper_name:
|
208
|
+
unsafe_helper_name: "foo",
|
209
209
|
parameters: {
|
210
|
-
safe_helper_name:
|
211
|
-
parameters: {parameter_name:
|
210
|
+
safe_helper_name: "bar",
|
211
|
+
parameters: {parameter_name: "baz"}
|
212
212
|
}
|
213
213
|
}
|
214
214
|
]
|
@@ -216,16 +216,16 @@ describe Handlebars::Parser do
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
context
|
219
|
+
context "as helpers" do
|
220
220
|
it 'recognizes the "as |...|" writing' do
|
221
|
-
expect(parser.parse(
|
221
|
+
expect(parser.parse("{{#each items as |item|}}plic{{/each}}")).to eq({
|
222
222
|
block_items: [
|
223
223
|
{
|
224
|
-
helper_name:
|
225
|
-
parameters: {parameter_name:
|
226
|
-
as_parameters: {parameter_name:
|
224
|
+
helper_name: "each",
|
225
|
+
parameters: {parameter_name: "items"},
|
226
|
+
as_parameters: {parameter_name: "item"},
|
227
227
|
block_items: [
|
228
|
-
{template_content:
|
228
|
+
{template_content: "plic"}
|
229
229
|
]
|
230
230
|
}
|
231
231
|
]
|
@@ -233,44 +233,44 @@ describe Handlebars::Parser do
|
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'supports the "else" statement' do
|
236
|
-
expect(parser.parse(
|
236
|
+
expect(parser.parse("{{#each items as |item|}}plic{{else}}Hummm, empty{{/each}}")).to eq({
|
237
237
|
block_items: [
|
238
238
|
{
|
239
|
-
helper_name:
|
240
|
-
parameters: {parameter_name:
|
241
|
-
as_parameters: {parameter_name:
|
239
|
+
helper_name: "each",
|
240
|
+
parameters: {parameter_name: "items"},
|
241
|
+
as_parameters: {parameter_name: "item"},
|
242
242
|
block_items: [
|
243
|
-
{template_content:
|
243
|
+
{template_content: "plic"}
|
244
244
|
],
|
245
245
|
else_block_items: [
|
246
|
-
{template_content:
|
246
|
+
{template_content: "Hummm, empty"}
|
247
247
|
]
|
248
248
|
}
|
249
249
|
]
|
250
250
|
})
|
251
251
|
end
|
252
252
|
|
253
|
-
it
|
254
|
-
expect(parser.parse(
|
253
|
+
it "can be imbricated" do
|
254
|
+
expect(parser.parse("{{#each items as |item|}}{{#each item as |char index|}}show item{{/each}}{{else}}Hummm, empty{{/each}}")).to eq({
|
255
255
|
block_items: [
|
256
256
|
{
|
257
|
-
helper_name:
|
258
|
-
parameters: {parameter_name:
|
259
|
-
as_parameters: {parameter_name:
|
257
|
+
helper_name: "each",
|
258
|
+
parameters: {parameter_name: "items"},
|
259
|
+
as_parameters: {parameter_name: "item"},
|
260
260
|
block_items: [
|
261
261
|
{
|
262
|
-
helper_name:
|
263
|
-
parameters: {parameter_name:
|
262
|
+
helper_name: "each",
|
263
|
+
parameters: {parameter_name: "item"},
|
264
264
|
as_parameters: [
|
265
|
-
{parameter_name:
|
266
|
-
{parameter_name:
|
265
|
+
{parameter_name: "char"},
|
266
|
+
{parameter_name: "index"}],
|
267
267
|
block_items: [
|
268
|
-
{template_content:
|
268
|
+
{template_content: "show item"}
|
269
269
|
]
|
270
270
|
}
|
271
271
|
],
|
272
272
|
else_block_items: [
|
273
|
-
{template_content:
|
273
|
+
{template_content: "Hummm, empty"}
|
274
274
|
]
|
275
275
|
}
|
276
276
|
]
|
@@ -278,61 +278,61 @@ describe Handlebars::Parser do
|
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
-
context
|
282
|
-
it
|
283
|
-
expect(parser.parse(
|
281
|
+
context "if block" do
|
282
|
+
it "simple" do
|
283
|
+
expect(parser.parse("{{#if something}}show something else{{/if}}")).to eq({
|
284
284
|
block_items: [
|
285
285
|
{
|
286
|
-
helper_name:
|
287
|
-
parameters: {parameter_name:
|
286
|
+
helper_name: "if",
|
287
|
+
parameters: {parameter_name: "something"},
|
288
288
|
block_items: [
|
289
|
-
{template_content:
|
289
|
+
{template_content: "show something else"}
|
290
290
|
]
|
291
291
|
}
|
292
292
|
]
|
293
293
|
})
|
294
294
|
end
|
295
295
|
|
296
|
-
it
|
297
|
-
expect(parser.parse(
|
296
|
+
it "with an else statement" do
|
297
|
+
expect(parser.parse("{{#if something}}Ok{{else}}not ok{{/if}}")).to eq({
|
298
298
|
block_items: [
|
299
299
|
{
|
300
|
-
helper_name:
|
301
|
-
parameters: {parameter_name:
|
300
|
+
helper_name: "if",
|
301
|
+
parameters: {parameter_name: "something"},
|
302
302
|
block_items: [
|
303
|
-
{template_content:
|
303
|
+
{template_content: "Ok"}
|
304
304
|
],
|
305
305
|
else_block_items: [
|
306
|
-
{template_content:
|
306
|
+
{template_content: "not ok"}
|
307
307
|
]
|
308
308
|
}
|
309
309
|
]
|
310
310
|
})
|
311
311
|
end
|
312
312
|
|
313
|
-
it
|
314
|
-
expect(parser.parse(
|
313
|
+
it "imbricated" do
|
314
|
+
expect(parser.parse("{{#if something}}{{#if another_thing}}Plic{{/if}}ploc{{/if}}")).to eq({
|
315
315
|
block_items: [
|
316
316
|
{
|
317
|
-
helper_name:
|
318
|
-
parameters: {parameter_name:
|
317
|
+
helper_name: "if",
|
318
|
+
parameters: {parameter_name: "something"},
|
319
319
|
block_items: [
|
320
320
|
{
|
321
|
-
helper_name:
|
322
|
-
parameters: {parameter_name:
|
321
|
+
helper_name: "if",
|
322
|
+
parameters: {parameter_name: "another_thing"},
|
323
323
|
block_items: [
|
324
|
-
{template_content:
|
324
|
+
{template_content: "Plic"}
|
325
325
|
]
|
326
326
|
},
|
327
|
-
{template_content:
|
327
|
+
{template_content: "ploc"}
|
328
328
|
]
|
329
329
|
}
|
330
330
|
]
|
331
331
|
})
|
332
332
|
end
|
333
333
|
|
334
|
-
it
|
335
|
-
expect(parser.parse(
|
334
|
+
it "imbricated block with elses" do
|
335
|
+
expect(parser.parse("{{#if something}}{{#if another_thing}}Case 1{{else}}Case 2{{/if}}{{else}}{{#if another_thing}}Case 3{{else}}Case 4{{/if}}{{/if}}")).to eq({
|
336
336
|
block_items: [
|
337
337
|
{
|
338
338
|
helper_name: "if",
|
@@ -375,43 +375,43 @@ describe Handlebars::Parser do
|
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
|
-
context
|
379
|
-
it
|
380
|
-
expect(parser.parse(
|
378
|
+
context "each block" do
|
379
|
+
it "simple" do
|
380
|
+
expect(parser.parse("{{#each people}} {{this.name}} {{/each}}")).to eq({
|
381
381
|
block_items: [
|
382
382
|
{
|
383
|
-
helper_name:
|
384
|
-
parameters: {parameter_name:
|
383
|
+
helper_name: "each",
|
384
|
+
parameters: {parameter_name: "people"},
|
385
385
|
block_items: [
|
386
|
-
{template_content:
|
387
|
-
{replaced_unsafe_item:
|
388
|
-
{template_content:
|
386
|
+
{template_content: " "},
|
387
|
+
{replaced_unsafe_item: "this.name"},
|
388
|
+
{template_content: " "}
|
389
389
|
]
|
390
390
|
}
|
391
391
|
]
|
392
392
|
})
|
393
393
|
end
|
394
394
|
|
395
|
-
it
|
396
|
-
expect(parser.parse(
|
395
|
+
it "imbricated" do
|
396
|
+
expect(parser.parse("{{#each people}} {{this.name}} <ul> {{#each this.contact}} <li>{{this}}</li> {{/each}}</ul>{{/each}}")).to eq({
|
397
397
|
block_items: [
|
398
398
|
{
|
399
|
-
helper_name:
|
400
|
-
parameters: {parameter_name:
|
399
|
+
helper_name: "each",
|
400
|
+
parameters: {parameter_name: "people"},
|
401
401
|
block_items: [
|
402
|
-
{template_content:
|
403
|
-
{replaced_unsafe_item:
|
404
|
-
{template_content:
|
402
|
+
{template_content: " "},
|
403
|
+
{replaced_unsafe_item: "this.name"},
|
404
|
+
{template_content: " <ul> "},
|
405
405
|
{
|
406
|
-
helper_name:
|
407
|
-
parameters: {parameter_name:
|
406
|
+
helper_name: "each",
|
407
|
+
parameters: {parameter_name: "this.contact"},
|
408
408
|
block_items: [
|
409
|
-
{template_content:
|
410
|
-
{replaced_unsafe_item:
|
411
|
-
{template_content:
|
409
|
+
{template_content: " <li>"},
|
410
|
+
{replaced_unsafe_item: "this"},
|
411
|
+
{template_content: "</li> "}
|
412
412
|
]
|
413
413
|
},
|
414
|
-
{template_content:
|
414
|
+
{template_content: "</ul>"}
|
415
415
|
]
|
416
416
|
}
|
417
417
|
]
|
@@ -419,37 +419,45 @@ describe Handlebars::Parser do
|
|
419
419
|
end
|
420
420
|
end
|
421
421
|
|
422
|
-
context
|
423
|
-
it
|
424
|
-
expect(parser.parse(
|
422
|
+
context "templates with single curlies" do
|
423
|
+
it "works with loose curlies" do
|
424
|
+
expect(parser.parse("} Hi { hey } {")).to eq({
|
425
|
+
block_items: [
|
426
|
+
{template_content: "} Hi { hey } {"}
|
427
|
+
]
|
428
|
+
})
|
429
|
+
end
|
430
|
+
|
431
|
+
it "works with groups of curlies" do
|
432
|
+
expect(parser.parse("{ Hi }{ hey }")).to eq({
|
425
433
|
block_items: [
|
426
|
-
{template_content:
|
434
|
+
{template_content: "{ Hi }{ hey }"}
|
427
435
|
]
|
428
436
|
})
|
429
437
|
end
|
430
438
|
|
431
|
-
it
|
432
|
-
expect(parser.parse(
|
439
|
+
it "works with closing curly before value" do
|
440
|
+
expect(parser.parse("Hi }{{ hey }}")).to eq({
|
433
441
|
block_items: [
|
434
|
-
{template_content:
|
442
|
+
{template_content: "Hi }"},
|
443
|
+
{replaced_unsafe_item: "hey"}
|
435
444
|
]
|
436
445
|
})
|
437
446
|
end
|
438
447
|
|
439
|
-
it
|
440
|
-
expect(parser.parse(
|
448
|
+
it "works with single empty curly pair" do
|
449
|
+
expect(parser.parse("Hi {} hey")).to eq({
|
441
450
|
block_items: [
|
442
|
-
{template_content:
|
443
|
-
{replaced_unsafe_item: 'hey'}
|
451
|
+
{template_content: "Hi {} hey"}
|
444
452
|
]
|
445
453
|
})
|
446
454
|
end
|
447
455
|
|
448
|
-
it
|
449
|
-
expect(parser.parse(
|
456
|
+
it "works with closing curly before value at the start" do
|
457
|
+
expect(parser.parse("}{{ hey }}")).to eq({
|
450
458
|
block_items: [
|
451
|
-
{template_content:
|
452
|
-
{replaced_unsafe_item:
|
459
|
+
{template_content: "}"},
|
460
|
+
{replaced_unsafe_item: "hey"}
|
453
461
|
]
|
454
462
|
})
|
455
463
|
end
|