Implement the first and last helpers.

This commit is contained in:
Tom Alexander
2020-06-07 15:16:39 -04:00
parent fdecdcb53b
commit 417466d17d
5 changed files with 188 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
{
"people": [
{
"name": "Alice",
"pet": "cat"
},
{
"name": "Bob",
"pet": "dog"
},
{
"name": "Chris",
"pet": "lizard"
}
],
"toys": [
"ball",
"bone"
],
"scalar": 7,
"name": "global name",
"pet": "global pet"
}

View File

@@ -0,0 +1,29 @@
Tags inside a last{~n}
=================={~n}
{#people}
{name}{@last petname="fluffy"},{pet}{petname}{/last}
{/people}{~n}
last inside a scalar{~n}
===================={~n}
{#scalar}
{name}{@last petname="fluffy"},{pet}{petname}{/last}
{/scalar}{~n}
Nested last inside another non-array section{~n}
============================================{~n}
{#people}
{#toys}
{name}'s pet {pet} plays with a {.}{@last}, {/last}
{/toys}
{/people}{~n}
Else block inside a last{~n}
========================{~n}
{#people}
{name}{@last},{pet}{petname}{:else}elseblock{/last}
{/people}{~n}
Sep outside any section{~n}
======================={~n}
{@last}last is printed outside any section{/last}