Added tests proving that the explicit context is evaluated using the global context of the partial containing the block (NOT the inline partial, which is where the explicit context is written).
This commit is contained in:
@@ -17,7 +17,7 @@ Explicitly setting a context in a partial also works. The explicit context takes
|
||||
|
||||
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`.
|
||||
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 `parameters->explicit`.
|
||||
|
||||
Helpers
|
||||
-------
|
||||
@@ -31,6 +31,8 @@ Explicitly setting a context on an inline partial does not work, but it does not
|
||||
|
||||
Explicitly setting a context on a block does work.
|
||||
|
||||
The explicit context for inline partials is evaluated in the context for that template file containing the block, not the inline partial (so, whatever the context is when we invoke the partial containing the block).
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{#block}
|
||||
{+pet_line}BLOCK: {contents}{~n}{/pet_line}
|
||||
{/block}
|
||||
{#inline_partial}
|
||||
{<pet_line:message}INLINE PARTIAL: {contents}{~n}{/pet_line}
|
||||
{/inline_partial}
|
||||
@@ -0,0 +1 @@
|
||||
{+pet_line}BLOCK: {contents}{~n}{/pet_line}
|
||||
@@ -0,0 +1,4 @@
|
||||
{#block.message}
|
||||
{>explicit_evaluation_time_split_default/}
|
||||
{/block.message}
|
||||
{<pet_line:message}INLINE PARTIAL: {contents}{~n}{/pet_line}
|
||||
@@ -28,5 +28,29 @@
|
||||
"pet": "cat"
|
||||
}
|
||||
},
|
||||
"empty_array": []
|
||||
"empty_array": [],
|
||||
"block": {
|
||||
"message": {
|
||||
"contents": "Explicit contexts are evaluated in the context of the block."
|
||||
}
|
||||
},
|
||||
"inline_partial": {
|
||||
"message": {
|
||||
"contents": "Explicit contexts are evaluated in the context of the inline partial."
|
||||
}
|
||||
},
|
||||
"contents": "Explicit contexts are evaluated in the global context.",
|
||||
"partial_context": {
|
||||
"block": {
|
||||
"message": {
|
||||
"contents": "Explicit contexts are evaluated in the context of the block inside the partial context."
|
||||
}
|
||||
},
|
||||
"inline_partial": {
|
||||
"message": {
|
||||
"contents": "Explicit contexts are evaluated in the context of the inline partial inside the partial context."
|
||||
}
|
||||
},
|
||||
"contents": "Explicit contexts are evaluated in the global context inside the partial context."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,3 +269,30 @@ Partial Overloaded Explicit with parameters{~n}
|
||||
{>other_friend:explicit friend="Dave" pet="rabbit"/}
|
||||
{/loop}
|
||||
|
||||
{! Is an explicit context on an inline partial evaluated in the context of the block or the context of the inline partial? !}
|
||||
Explicit Evaluation Time Global{~n}
|
||||
==============================={~n}
|
||||
{>explicit_evaluation_time/}
|
||||
|
||||
Explicit Evaluation Time Partial Context{~n}
|
||||
========================================{~n}
|
||||
{#partial_context}
|
||||
{>explicit_evaluation_time/}
|
||||
{/partial_context}
|
||||
|
||||
{! The previous test discovered that the inline partial's explicit context is evaluated based on the context when invoking the full-blown partial, HOWEVER, it shared the same partial context for both the block and the inline partial. To conclusively prove if the explicit context is evaluated on the inline partial and not the block, we need a different partial context for each one. !}
|
||||
Explicit Evaluation Time Split Partial Context Default{~n}
|
||||
======================================================{~n}
|
||||
{#partial_context}
|
||||
{#block.message}
|
||||
{>explicit_evaluation_time_split_default/}
|
||||
{/block.message}
|
||||
{/partial_context}
|
||||
|
||||
Explicit Evaluation Time Split Partial Context OVerride{~n}
|
||||
======================================================={~n}
|
||||
{#partial_context}
|
||||
{#inline_partial}
|
||||
{>explicit_evaluation_time_split_override/}
|
||||
{/inline_partial}
|
||||
{/partial_context}
|
||||
|
||||
Reference in New Issue
Block a user