Design

Smart conditional blocks

Show or hide an entire table, paragraph, ..., row with one simple Carbone tag
ENTERPRISE FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v4.0+ 

Why is it smart?

Why should you use smart conditional blocks instead of hideBegin/hideEnd or showBegin/showEnd or array filters?

Compatible with DOCX, ODT, ODS, ODP, PDF, XLSX, and HTML documents.

A Carbone tag using :drop or :keep does not print anything in the generated report. The tag is removed when executed.

:drop/:keep(element)

Use the :drop formatter to remove elements from a document if the specified condition is true.
The :keep formatter works oppositely. It retains elements if the condition is true.

Element Description Accepted tag position
row Drop or keep a table row In a table row
p Drop or keep a paragraph Within a paragraph
img Drop or keep an image Image title, description, or alt text
table Drop or keep a table Inside a table cell
chart Drop or keep a chart Alternative text of the chart
shape Drop or keep a shape Title, description, or alt text
slide Drop or keep a slide Inside a text box (ODP only)
item Drop or keep a list item Within a list item (ODP/ODT only)
sheet Drop or keep a sheet Inside a table cell (ODS only)

A second parameter can be used with p and row to drop or keep the next N paragraphs or rows. Example:

Known limitation:

Examples

Drop rows of the table if an item name contains 'Falcon':

data
[
  { "name": "Falcon 9" },
  { "name": "Model S" },
  { "name": "Model 3" },
  { "name": "Falcon Heavy" }
]
template
Planes{d[i].name}
{d[i].name:ifIN('Falcon'):drop(row)}
{d[i+1].name}
Carbone Merge Icon
result
PlanesModel S
Model 3

Delete the entire table if the array length is lower than 6:

data
[
  { "name": "Bob" }
]
template
Planes {d:len:ifLT(6):drop(table)}{d[i].name}
{d[i+1].name}
Carbone Merge Icon
result

Tutorials