Add a test for explicit context setting.
This commit is contained in:
parent
d813a878ca
commit
e27ab16e06
1
js/test_cases/explicit_context_setting/README.md
Normal file
1
js/test_cases/explicit_context_setting/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
It seems $idx and $len do not survive through an explicit context setting, which will work perfectly with my injected-context architecture.
|
23
js/test_cases/explicit_context_setting/input1.json
Normal file
23
js/test_cases/explicit_context_setting/input1.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"some_global": "dog",
|
||||||
|
"loop": [
|
||||||
|
{
|
||||||
|
"person": {
|
||||||
|
"name": "Alice"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"person": {
|
||||||
|
"name": "Bob"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"person": {
|
||||||
|
"name": "Chris"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"explicit": {
|
||||||
|
"pet": "cat"
|
||||||
|
}
|
||||||
|
}
|
13
js/test_cases/explicit_context_setting/main.dust
Normal file
13
js/test_cases/explicit_context_setting/main.dust
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{! First we do it without explicit context setting which results in being able to read some_global but not pet !}
|
||||||
|
{#loop}
|
||||||
|
{#person}
|
||||||
|
{$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||||
|
{/person}
|
||||||
|
{/loop}
|
||||||
|
|
||||||
|
{! Then we do it with explicit context setting which should result in being able ot read pet but not some_global !}
|
||||||
|
{#loop}
|
||||||
|
{#person:explicit}
|
||||||
|
{$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||||
|
{/person}
|
||||||
|
{/loop}
|
Loading…
x
Reference in New Issue
Block a user