Expand the explicit context setting test to prove that injected_context gets inserted AFTER the current context when an explicit context is used.

This commit is contained in:
Tom Alexander 2020-05-25 16:21:25 -04:00
parent 17121aa85b
commit 4ce0899279
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 23 additions and 3 deletions

View File

@ -17,6 +17,8 @@ Explicitly setting a context in a partial also works. The explicit context takes
This works for both regular named partials and quoted partials. This works for both regular named partials and quoted partials.
While normally parameters are injected 1 level above the current context, if both parameters and explicit are set, they are injected below the current context. So if the context tree was `1->2->3`, with just parameters you'd have `1->2->parameters->3` but with an explicit context you have `1->2->3->parameters->explicit`.
Helpers Helpers
------- -------

View File

@ -4,17 +4,20 @@
{ {
"person": { "person": {
"name": "Alice" "name": "Alice"
} },
"friend": "Bob"
}, },
{ {
"person": { "person": {
"name": "Bob" "name": "Bob"
} },
"friend": "Chris"
}, },
{ {
"person": { "person": {
"name": "Chris" "name": "Chris"
} },
"friend": "Alice"
} }
], ],
"explicit": { "explicit": {

View File

@ -255,3 +255,17 @@ Falsey Explicit Path Explicit{~n}
{.|js}{~n} {.|js}{~n}
{/foo} {/foo}
{/loop} {/loop}
{! Since partial parameters are normally injected 1 level above the current context, and explicit contexts are below the partial parameters, is the order parameters->current_context->explicit or current_context->parameters->explicit when both are being used? !}
Partial Overloaded Regular with parameters{~n}
=========================================={~n}
{#loop}
{>other_friend friend="Dave" pet="rabbit"/}
{/loop}
Partial Overloaded Explicit with parameters{~n}
==========================================={~n}
{#loop}
{>other_friend:explicit friend="Dave" pet="rabbit"/}
{/loop}

View File

@ -0,0 +1 @@
{$idx}: {person.name}'s friend {friend} has a pet {pet} but not a {some_global}{~n}