Add tests for reference parameters.

This commit is contained in:
Tom Alexander 2020-05-30 15:20:54 -04:00
parent 0236f882b7
commit 4932a4bb6f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1 @@
Reference parameters are evaluated at the time of render, as opposed to direct parameters which are evaluated at the time of assignment.

View File

@ -0,0 +1,15 @@
{
"name": "Bob",
"people": [
{
"name": "Alice",
"petname": "rover"
}
],
"truthy": "some truthy value",
"other_petname": [
{
"petname": "spot"
}
]
}

View File

@ -0,0 +1,52 @@
Hello {name}, nice {pet}{~n}
{#people}
Hello {name}, nice {pet}{~n}
{/people}
{#people name="chris" pet="cat"}
Hello {name}, nice {pet}{~n}
{/people}
Reference Parameters{~n}
===================={~n}
{#people name="chris" pet="{petname}" petname="whiskers"}
Hello {name}, nice {pet}{~n}
{/people}
{#people}
{#truthy name="chris" pet="{petname}" petname="whiskers"}
Hello {name}, nice {pet}{~n}
{/truthy}
{/people}
{#people name="chris" pet="{petname}" petname="whiskers"}
{#other_petname}
Hello {name}, nice {pet}{~n}
{/other_petname}
{/people}
{! Can you have additional text in reference parameters, or just the reference !}
{#people name="chris" pet="{petname}!" petname="whiskers"}
{#other_petname}
Hello {name}, nice {pet}{~n}
{/other_petname}
{/people}
{! Can you have filters !}
{#people name="chris" pet="{petname|js}" petname="whiskers"}
{#other_petname}
Hello {name}, nice {pet}{~n}
{/other_petname}
{/people}
Direct Parameters{~n}
================={~n}
{#people name="chris" pet=petname petname="whiskers"}
Hello {name}, nice {pet}{~n}
{/people}
{#people}
{#truthy name="chris" pet=petname petname="whiskers"}
Hello {name}, nice {pet}{~n}
{/truthy}
{/people}
{#people name="chris" pet=petname petname="whiskers"}
{#other_petname}
Hello {name}, nice {pet}{~n}
{/other_petname}
{/people}