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 between hideBegin and hideEnd 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 string

  • ifEM (): 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.

Conditioned output example

Data

{
  "status1" : 1,
  "status2" : 2,
  "status3" : 3
}

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) }

Drop(element)

Compatibility

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

  • to drop a group of elements, use hideBegin()/hideEnd() or showBegin()/showEnd()

  • use the drop formatter to delete elements from a document. The first argument passed to :drop(argument1) is the element to drop

Use the following arguments to drop an element:

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)}

  • include the tag within the image title, description, or alternative text (external help page)

chart to drop charts

  • usage: {d.dataset:ifEM:drop(chart)}

  • include the tag within the alternative text of the graphic (external help page)

shape to drop shape (square, circle, arrows, etc.)

  • usage: {d.dataset:ifEM:drop(chart)}

  • include the tag within the title, description or alternative text of the shape (external help page)

showBegin()/showEnd()

Shows a text block between showBegin and showEnd if a condition is true.

Use only break lines (shift + Enter) between showBegin and showEnd.

Learn more about why conditional formatters are adding empty lines.

Data

{
  "toBuy" : true
}

Banana{d.toBuy:ifEQ(true):showBegin} Apple Pineapple {d.toBuy:showEnd}grapes

hideBegin()/hideEnd()

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
}

Banana{d.toBuy:ifEQ(true):hideBegin} Apple Pineapple {d.toBuy:hideEnd}grapes

and( value )

Changes the default operator between conditional formatters.

Example

{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'

ParametersDescriptionType

value

[optional] new value to test

mixed

or( value )

Changes the default operator between conditional formatters.

Example

{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'

ParametersDescriptionType

value

[optional] new value to test

mixed

ifEM( )

Matches empty values, string, arrays or objects (null, undefined, [], {}, ...).

Examples

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"

ifNEM( )

Matches not empty values, string, arrays or objects.

Examples

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"

ifEQ( value )

  • 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

ParametersDescriptionType

value

value to test

string, integer

Examples

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"

ifNE( value )

  • 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

ParametersDescriptionType

value

value to test

string, integer

Examples

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"

ifGT( value )

Matches values that are greater than a specified value.

ParametersDescriptionType

value

value to test

integer

Examples

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"

ifGTE( value )

Matches values that are greater than or equal to a specified value.

ParametersDescriptionType

value

value to test

integer

Examples

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"

ifLT( value )

Matches values that are less than a specified value.

ParametersDescriptionType

value

value to test

integer

Examples

-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"

ifLTE( value )

Matches values that are less than or equal to a specified value.

ParametersDescriptionType

value

value to test

integer

Examples

-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"

ifIN( value )

Matches any of the values specified in an array or string.

ParametersDescriptionType

value

value to test

integer

Examples

'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"

ifNIN( value )

Matches none of the values specified in an array or string.

ParametersDescriptionType

value

value to test

integer

Examples

'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"

show( message )

  • prints a message if the condition is true

  • use with other formatters to print conditional content

ParametersDescriptionType

message

message to print

Examples

'Carbone.io':show() // "Carbone.io"

elseShow( message )

  • print a message if the condition is false

  • use with other formatters to print conditional content

ParametersDescriptionType

message

message to print

Last updated