diff --git a/js/test_cases/explicit_context_setting/README.md b/js/test_cases/explicit_context_setting/README.md new file mode 100644 index 0000000..ff56da7 --- /dev/null +++ b/js/test_cases/explicit_context_setting/README.md @@ -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. diff --git a/js/test_cases/explicit_context_setting/input1.json b/js/test_cases/explicit_context_setting/input1.json new file mode 100644 index 0000000..2e6e506 --- /dev/null +++ b/js/test_cases/explicit_context_setting/input1.json @@ -0,0 +1,23 @@ +{ + "some_global": "dog", + "loop": [ + { + "person": { + "name": "Alice" + } + }, + { + "person": { + "name": "Bob" + } + }, + { + "person": { + "name": "Chris" + } + } + ], + "explicit": { + "pet": "cat" + } +} diff --git a/js/test_cases/explicit_context_setting/main.dust b/js/test_cases/explicit_context_setting/main.dust new file mode 100644 index 0000000..5a0938b --- /dev/null +++ b/js/test_cases/explicit_context_setting/main.dust @@ -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}