Add tests that prove that the priority between explicit contexts and parameters varies across sections and partials.

This commit is contained in:
Tom Alexander 2020-05-25 20:23:10 -04:00
parent 92ad15ff85
commit 0ca17e0885
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 46 additions and 1 deletions

View File

@ -1,3 +1,9 @@
Priority
--------
Partials: Explicit context takes priority over parameters
Sections: New context takes priority, then parameters, then explicit
$idx and $len
-------------
@ -6,7 +12,7 @@ $idx and $len do not survive through an explicit context setting, which will wor
You can use $idx and $len as your explicit context, but as scalar values I do not think there is a way to access them anyway.
Exists and Not-Exists
=====================
---------------------
Looks like you can exlicitly set a context with exists and not-exists tags too. This works out well in the parser because I am using the same code for those blocks.

View File

@ -1,4 +1,9 @@
{
"another_idx": {
"$idx": 21,
"$len": 22,
"other": 23
},
"block": {
"message": {
"contents": "Explicit contexts are evaluated in the context of the block."
@ -14,6 +19,9 @@
"explicit": {
"pet": "cat"
},
"has_idx": {
"$idx": 14
},
"inline_partial": {
"message": {
"contents": "Explicit contexts are evaluated in the context of the inline partial."

View File

@ -296,3 +296,33 @@ Explicit Evaluation Time Split Partial Context OVerride{~n}
{>explicit_evaluation_time_split_override/}
{/inline_partial}
{/partial_context}
{! What happens with sections with explicit context and parameters !}
Section set $idx as a parameter{~n}
==============================={~n}
{#explicit $idx="7"}
$idx is {$idx}{~n}
$len is {$len}{~n}
{/explicit}
Section set $idx as a parameter and new context{~n}
==============================================={~n}
{#has_idx $idx="7"}
$idx is {$idx}{~n}
$len is {$len}{~n}
{/has_idx}
Section set $idx as a parameter, new context, and explicit context{~n}
=================================================================={~n}
{#has_idx:another_idx $idx="7" $len="8"}
$idx is {$idx}{~n}
$len is {$len}{~n}
other is {other}{~n}
{/has_idx}
Section vs Partial priority{~n}
==========================={~n}
{#some_global:explicit pet="snake"}
{pet}{~n}
{/some_global}
{>priority:explicit pet="snake"/}

View File

@ -0,0 +1 @@
{pet}{~n}