Add tests that prove that the priority between explicit contexts and parameters varies across sections and partials.
This commit is contained in:
parent
92ad15ff85
commit
0ca17e0885
@ -1,3 +1,9 @@
|
|||||||
|
Priority
|
||||||
|
--------
|
||||||
|
Partials: Explicit context takes priority over parameters
|
||||||
|
|
||||||
|
Sections: New context takes priority, then parameters, then explicit
|
||||||
|
|
||||||
$idx and $len
|
$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.
|
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
|
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.
|
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.
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"another_idx": {
|
||||||
|
"$idx": 21,
|
||||||
|
"$len": 22,
|
||||||
|
"other": 23
|
||||||
|
},
|
||||||
"block": {
|
"block": {
|
||||||
"message": {
|
"message": {
|
||||||
"contents": "Explicit contexts are evaluated in the context of the block."
|
"contents": "Explicit contexts are evaluated in the context of the block."
|
||||||
@ -14,6 +19,9 @@
|
|||||||
"explicit": {
|
"explicit": {
|
||||||
"pet": "cat"
|
"pet": "cat"
|
||||||
},
|
},
|
||||||
|
"has_idx": {
|
||||||
|
"$idx": 14
|
||||||
|
},
|
||||||
"inline_partial": {
|
"inline_partial": {
|
||||||
"message": {
|
"message": {
|
||||||
"contents": "Explicit contexts are evaluated in the context of the inline partial."
|
"contents": "Explicit contexts are evaluated in the context of the inline partial."
|
||||||
|
@ -296,3 +296,33 @@ Explicit Evaluation Time Split Partial Context OVerride{~n}
|
|||||||
{>explicit_evaluation_time_split_override/}
|
{>explicit_evaluation_time_split_override/}
|
||||||
{/inline_partial}
|
{/inline_partial}
|
||||||
{/partial_context}
|
{/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"/}
|
||||||
|
1
js/test_cases/explicit_context_setting/priority.dust
Normal file
1
js/test_cases/explicit_context_setting/priority.dust
Normal file
@ -0,0 +1 @@
|
|||||||
|
{pet}{~n}
|
Loading…
x
Reference in New Issue
Block a user