Releases: code4ward/JSOI
Conditional Object Loading
Release Notes
Conditional Loading objects with Expressions
JSOI now supports combining conditional loading with expressions. This functionality is supported by combining conditional loading
and expressions. The <-IF(expression) is supported along with <--IF(expression) and support for
<-ELSE.
Example
The examples below highlight this functionality in yaml since it may be easier to read then json.
1️⃣ Consider the following template Object:
Sub:
"<-IF(({{ FirstN }} == 10) && ({{ SecondN }} != 10))":
A: 10
B: '2'
C:
D: 'Yes'
"<-ELSE":
A: 1
2️⃣ With the following keys:
FirstN: 10
SecondN: 113️⃣ When interpolating the following result will be produced:
Sub:
A: 10
B: '2'
C:
D: 'Yes'Example
The order of
<-IFand<-ELSEwithin the object will not impact the result.
1️⃣ Consider the following template Object:
Sub:
"<-ELSE":
A: 1
"<-IF(({{ FirstN }} == 10) && ({{ SecondN }} != 10))":
A: 10
B: '2'
C:
D: 'Yes'2️⃣ With the following keys:
FirstN: 10
SecondN: 113️⃣ When interpolating the following result will be produced:
Sub:
A: 10
B: '2'
C:
D: 'Yes'Example
When using string make sure to wrap them in single quotes
1️⃣
Sub:
"<-IF('{{ DEBUG }}' == 'Yes')":
A: Debug is on
"<-ELSE":
A: Debug is off2️⃣ With the following keys:
Sub:
DEBUG: 'Yes'3️⃣ When interpolating the following result will be produced:
A: Debug is on