Conditioned output
No formatters can be chained after
hideBegin
, hideEnd
, showBegin
, showEnd
.By default, condition formatters have a special behavior, the formatter's result is not propagated to the next formatter if the result of the condition is true. This enables test chaining with Dynamic parameters.
Hide and show a part of the document with the following formatters:
hideBegin
/hideEnd
: hide text block betweenhideBegin
andhideEnd
if condition is true.showBegin
/showEnd
: show a text block between showBegin and showEnd if condition is true.ifEQ (value)
: Matches values that are equal to a specified value.ifNE (value)
: Matches all values that are not equal to a specified value.ifGT (value)
: Matches values that are greater than a specified value.ifGTE (value)
: Matches values that are greater than or equal to a specified value.ifLT (value)
: Matches values that are less than a specified value.ifLTE (value)
: Matches values that are less than or equal to a specified value.ifIN (value)
: Matches any of the values specified in an array or string.ifNIN (value)
: Matches none of the values specified in an array or stringifEM ()
: Matches empty values, string, arrays or objects.ifNEM ()
: Matches not empty values, string, arrays or objects.and (value)
:AND
operator between two consecutive conditional formatters.or (value)
: (default)OR
operator between 2 consecutive conditional formatters.show (message)
: print a message if a condition is true.elseShow (message)
: print a message if a condition is false.
Data
{
"status1" : 1,
"status2" : 2,
"status3" : 3
}
Template
Result
one = { d.status1:ifEQ(2):show(two):or(.status1):ifEQ(1):show(one):elseShow(unknown) }
two = { d.status2:ifEQ(2):show(two):or(.status2):ifEQ(1):show(one):elseShow(unknown) }
three = { d.status3:ifEQ(2):show(two):or(.status3):ifEQ(1):show(one):elseShow(unknown) }
one = "one"
two = "two"
three = "unknown"
Supported file formats:
DOCX
, ODT
, and PDF
.- when you use the
drop
formatter, the tag value is not printed and chained formatters are not executed - use the
drop
formatter to delete elements from a document. The first argument passed to:drop(argument1)
is the element to drop
p
to drop paragraphs- usage:
{d.text:ifEM:drop(p)}
- include the tag within a paragraph, and all the elements it comprises are also removed if the condition is validated (external help page)
row
to drop table rows- usage:
{d.data:ifEM:drop(row)}
- include the tag in a table row, and all the elements it comprises are also deleted if the condition is validated (external help page)
Optionally, use
nbrRowsToHide
to set the number of rows to drop as a second argument {d.data:ifEM:drop(row, nbrRowsToHide)}
, such as {d.data:ifEM:drop(row, 3)}
, meaning the current and next two rows is removed if the condition is validated.By default, the formatter
:drop(row)
hides only the current row.img
to drop pictures- usage:
{d.img:ifEM:drop(img)}
chart
to drop charts- usage:
{d.dataset:ifEM:drop(chart)}
shape
to drop shape (square, circle, arrows, etc.)- usage:
{d.dataset:ifEM:drop(chart)}
Shows a text block between
showBegin
and showEnd
if a condition is true.Use only break lines (
shift
+ Enter
) between showBegin
and showEnd
. Data
{
"toBuy" : true
}
Template
Result
Banana{d.toBuy:ifEQ(true):showBegin}
Apple
Pineapple
{d.toBuy:showEnd}grapes
Banana
Apple
Pineapple
grapes
Hides a text block between
hideBegin
and hideEnd
if a condition is true.Use only break lines (
shift
+ Enter
) between hideBegin
and hideEnd
. Learn more about why conditional formatters are adding empty lines.Data
{
"toBuy" : true
}
Template
Result
Banana{d.toBuy:ifEQ(true):hideBegin}
Apple
Pineapple
{d.toBuy:hideEnd}grapes
Banana
grapes
Changes the default operator between conditional formatters.
{d.car:ifEQ('delorean'):and(.speed):ifGT(80):show('TravelInTime'):elseShow('StayHere')}
means "if d.car equals 'delorean' AND d.speed is greater than 80, then it prints 'TravelInTime', otherwise it prints 'StayHere'Parameters | Description | Type |
---|---|---|
value | [optional] new value to test | mixed |
Changes the default operator between conditional formatters.
{d.car:ifEQ('delorean'):or(.speed):ifGT(80):show('TravelInTime'):elseShow('StayHere')}
means "if d.car equals 'delorean' OR d.speed is greater than 80, then it prints 'TravelInTime', otherwise
it prints 'StayHere'Parameters | Description | Type |
---|---|---|
value | [optional] new value to test | mixed |
Matches empty values, string, arrays or objects (null, undefined, [], {}, ...).
null:ifEM():show('Result true'):elseShow('Result false') // "Result true"
[]:ifEM():show('Result true'):elseShow('Result false') // "Result true"
{}:ifEM():show('Result true'):elseShow('Result false') // "Result true"
'':ifEM():show('Result true'):elseShow('Result false') // "Result true"
0:ifEM():show('Result true'):elseShow('Result false') // "Result false"
'homer':ifEM():show('Result true'):elseShow('Result false') // "Result false"
[23]:ifEM():show('Result true'):elseShow('Result false') // "Result false"
{'id':3}:ifEM():show('Result true'):elseShow('Result false') // "Result false"
Matches not empty values, string, arrays or objects.
0:ifNEM():show('Result true'):elseShow('Result false') // "Result true"
'homer':ifNEM():show('Result true'):elseShow('Result false') // "Result true"
[23]:ifNEM():show('Result true'):elseShow('Result false') // "Result true"
{'id':3}:ifNEM():show('Result true'):elseShow('Result false') // "Result true"
null:ifNEM():show('Result true'):elseShow('Result false') // "Result false"
[]:ifNEM():show('Result true'):elseShow('Result false') // "Result false"
{}:ifNEM():show('Result true'):elseShow('Result false') // "Result false"
'':ifNEM():show('Result true'):elseShow('Result false') // "Result false"
- matches all values that are equal to a specified value
- can be combined with other formatters to create conditional content
- returns the initial marker
- the state of the condition is not returned
Parameters | Description | Type |
---|---|---|
value | value to test | string, integer |
100:ifEQ(100):show('Result true'):elseShow('Result false') // "Result true"
100:ifEQ(101):show('Result true'):elseShow('Result false') // "Result false"
'homer':ifEQ('homer'):show('Result true'):elseShow('Result false') // "Result true"
'homer':ifEQ('bart'):show('Result true'):elseShow('Result false') // "Result false"
'':ifEQ(''):show('Result true'):elseShow('Result false') // "Result true"
null:ifEQ(100):show('Result true'):elseShow('Result false') // "Result false"
null:ifEQ(null):show('Result true'):elseShow('Result false') // "Result true"
0:ifEQ(100):show('Result true'):elseShow('Result false') // "Result false"
- matches all values that are not equal to a specified value
- can be combined with other formatters to create conditional content
- returns the initial marker
- the state of the condition is not returned
Parameters | Description | Type |
---|---|---|
value | value to test | string, integer |
100:ifNE(100):show('Result true'):elseShow('Result false') // "Result false"
100:ifNE(101):show('Result true'):elseShow('Result false') // "Result true"
'homer':ifNE('homer'):show('Result true'):elseShow('Result false') // "Result false"
'homer':ifNE('bart'):show('Result true'):elseShow('Result false') // "Result true"
'':ifNE(''):show('Result true'):elseShow('Result false') // "Result false"
null:ifNE(100):show('Result true'):elseShow('Result false') // "Result true"
null:ifNE(null):show('Result true'):elseShow('Result false') // "Result false"
0:ifNE(100):show('Result true'):elseShow('Result false') // "Result true"
Matches values that are greater than a specified value.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
1234:ifGT(1):show('Result true'):elseShow('Result false') // "Result true"
'50':ifGT('-29'):show('Result true'):elseShow('Result false') // "Result true"
'32q':ifGT('4q2'):show('Result true'):elseShow('Result false') // "Result true"
'1234Hello':ifGT('1'):show('Result true'):elseShow('Result false') // "Result true"
'10':ifGT('8Hello1234'):show('Result true'):elseShow('Result false') // "Result true"
-23:ifGT(19):show('Result true'):elseShow('Result false') // "Result false"
1:ifGT(768):show('Result true'):elseShow('Result false') // "Result false"
0:ifGT(0):show('Result true'):elseShow('Result false') // "Result false"
-2891:ifGT('33Hello'):show('Result true'):elseShow('Result false') // "Result false"
Matches values that are greater than or equal to a specified value.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
50:ifGTE(-29):show('Result true'):elseShow('Result false') // "Result true"
1:ifGTE(1):show('Result true'):elseShow('Result false') // "Result true"
1290:ifGTE(768):show('Result true'):elseShow('Result false') // "Result true"
'1234':ifGTE('1'):show('Result true'):elseShow('Result false') // "Result true"
-23:ifGTE(19):show('Result true'):elseShow('Result false') // "Result false"
1:ifGTE(768):show('Result true'):elseShow('Result false') // "Result false"
'1':ifGTE('1234'):show('Result true'):elseShow('Result false') // "Result false"
Matches values that are less than a specified value.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
-23:ifLT(19):show('Result true'):elseShow('Result false') // "Result true"
1:ifLT(768):show('Result true'):elseShow('Result false') // "Result true"
'1':ifLT('1234'):show('Result true'):elseShow('Result false') // "Result true"
'123dsf':ifLT('103123'):show('Result true'):elseShow('Result false') // "Result true"
-1299283:ifLT('-2891feihuwf'):show('Result true'):elseShow('Result false') // "Result true"
50:ifLT(-29):show('Result true'):elseShow('Result false') // "Result false"
0:ifLT(0):show('Result true'):elseShow('Result false') // "Result false"
1290:ifLT(768):show('Result true'):elseShow('Result false') // "Result false"
'1234':ifLT('1'):show('Result true'):elseShow('Result false') // "Result false"
Matches values that are less than or equal to a specified value.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
-23:ifLTE(19):show('Result true'):elseShow('Result false') // "Result true"
1:ifLTE(768):show('Result true'):elseShow('Result false') // "Result true"
5:ifLTE(5):show('Result true'):elseShow('Result false') // "Result true"
'1':ifLTE('1234'):show('Result true'):elseShow('Result false') // "Result true"
1290:ifLTE(768):show('Result true'):elseShow('Result false') // "Result false"
'1234':ifLTE('1'):show('Result true'):elseShow('Result false') // "Result false"
Matches any of the values specified in an array or string.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
'car is broken':ifIN('is'):show('Result true'):elseShow('Result false') // "Result true"
[1,2,'toto']:ifIN(2):show('Result true'):elseShow('Result false') // "Result true"
'car is broken':ifIN('are'):show('Result true'):elseShow('Result false') // "Result false"
[1,2,'toto']:ifIN('titi'):show('Result true'):elseShow('Result false') // "Result false"
Matches none of the values specified in an array or string.
Parameters | Description | Type |
---|---|---|
value | value to test | integer |
'car is broken':ifNIN('are'):show('Result true'):elseShow('Result false') // "Result true"
[1,2,'toto']:ifNIN('titi'):show('Result true'):elseShow('Result false') // "Result true"
'car is broken':ifNIN('is'):show('Result true'):elseShow('Result false') // "Result false"
[1,2,'toto']:ifNIN(2):show('Result true'):elseShow('Result false') // "Result false"
- prints a message if the condition is true
- use with other formatters to print conditional content
Parameters | Description | Type |
---|---|---|
message | message to print | |
'Carbone.io':show() // "Carbone.io"
- print a message if the condition is false
- use with other formatters to print conditional content
Parameters | Description | Type |
---|---|---|
message | message to print | |
Last modified 8mo ago