addIf

Make a group of two or three consecutive values and only print the first and/or last value of each group if the main value is defined.

1
{{$addIf [value1] [value2] [value3] [value4]...}}
Example
format JSON XML
Data JSON
1
2
3
4
5
6
7
{
"Address": {
"country": "Chocolate",
"state": "Free",
"street": "123"
}
}
Code
1
2
3
4
5
6
7
8
9
10
11
12
{{$addIf
"Street: "
Address.street
" City: "
Address.city
" State: "
Address.state
" Country: "
Address.country
" World: "
Address.world
}}
Result
Data XML
1
2
3
4
5
<Address
country="Chocolate"
state="Free"
street="123">
</Address>
HTML
1
2
3
4
5
6
7
8
9
10
11
12
{{$addIf
"Street: "
Address._street
" City: "
Address._city
" State: "
Address._state
" Country: "
Address._country
" World: "
Address._world
}}
Result

Params

1
2
3
4
5
{{addIf
"add value" "string value" "add value"
side="both"
trimLast=true
}}
1
2
3
4
{{addIf
"add value" "string value"
side="left"
}}
1
2
3
4
{{addIf
"string value" "add value"
side="right"
}}

Options

sideleft
right
both
trimLasttrue/false
Remove the last add value for the last group, only works for side=”both” and side=”right”