@@ -10,52 +10,71 @@ test("add unbind tag", t => {
10
10
test ( "rewrite unquoted bookshop tags" , t => {
11
11
const input = `{% bookshop component prop: page.item %}` ;
12
12
const expected = `{% include _bookshop_component prop: page.item %}` ;
13
- t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
13
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
14
14
} ) ;
15
15
16
16
test ( "rewrite bookshop tags" , t => {
17
17
const input = `{% bookshop "component" prop: page.item %}` ;
18
18
const expected = `{% include "_bookshop_component" prop: page.item %}` ;
19
- t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
19
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
20
20
} ) ;
21
21
22
+ test ( "rewrite dynamic bookshop tags" , t => {
23
+ const input = `{% bookshop "{{ _bookshop_name }}" prop: page.item %}` ;
24
+ const expected = `{% include "_bookshop_{{ _bookshop_name }}" prop: page.item %}` ;
25
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
26
+ } ) ;
27
+
28
+ test ( "rewrite unquoted dynamic bookshop tags" , t => {
29
+ const input = `{% bookshop {{ _bookshop_name }} prop: page.item %}` ;
30
+ const expected = `{% include "_bookshop_{{ _bookshop_name }}" prop: page.item %}` ;
31
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
32
+ } ) ;
33
+
34
+ test ( "rewrite unquoted dynamic bookshop include tags" , t => {
35
+ const input = `{% bookshop_include {{ _bookshop_name }} prop: page.item %}` ;
36
+ const expected = `{% include "_bookshop_include_{{ _bookshop_name }}" prop: page.item %}` ;
37
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
38
+ } ) ;
39
+
40
+
22
41
test ( "rewrite bookshop_include tags" , t => {
23
42
const input = `{% bookshop_include "helper" prop: page.item %}` ;
24
43
const expected = `{% include "_bookshop_include_helper" prop: page.item %}` ;
25
- t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
44
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , expected ) ;
26
45
} ) ;
27
46
28
47
test ( "ignore the rest" , t => {
29
48
const input = `<div><h1>{{ title | default: "Hello World" }}</h1></div>` ;
30
- t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , input ) ;
49
+ t . is ( translateLiquid ( input , { expandBindSyntax : false , liveMarkup : false } ) , input ) ;
31
50
} ) ;
32
51
33
52
test ( "add live markup to bookshop tags" , t => {
34
53
const input = `{% bookshop "component" prop: page.item %}` ;
35
54
const expected = `<!--bookshop-live name(component) params(prop: page.item)-->{% include "_bookshop_component" prop: page.item %}<!--bookshop-live end-->` ;
36
- t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
55
+ t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
37
56
} ) ;
38
57
39
58
test ( "add live markup to bookshop_include tags" , t => {
40
59
const input = `{% bookshop_include "helper" prop: page.item %}` ;
41
60
const expected = `<!--bookshop-live name(helper) params(prop: page.item)-->{% include "_bookshop_include_helper" prop: page.item %}<!--bookshop-live end-->` ;
42
- t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
61
+ t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
43
62
} ) ;
44
63
45
64
test ( "add live markup to assigns" , t => {
46
65
const input = `{% assign a=b %}` ;
47
66
const expected = `{% assign a=b %}<!--bookshop-live context(a="{{a}}")-->` ;
48
- t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
67
+ t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
49
68
} ) ;
50
69
51
70
test ( "add live markup to local assigns" , t => {
52
71
const input = `{% local a=b %}` ;
53
72
const expected = `{% local a=b %}<!--bookshop-live context(a="{{a}}")-->` ;
54
- t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
73
+ t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
55
74
} ) ;
56
75
57
76
test ( "add live markup to loops" , t => {
58
77
const input = `{% for a in b %}` ;
59
78
const expected = `{% for a in b %}{% loop_context a in b %}` ;
60
- t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
79
+ t . is ( translateLiquid ( input , { expandBindSyntax : false } ) , expected ) ;
61
80
} ) ;
0 commit comments