---
source: https://carbone.io/documentation/design/conditions/inline-conditions.html
title: "Inline Conditions"
description: "How to conditionally print a text?"
generated_at: "2026-07-10"
---

# Inline Conditions

How to conditionally print a text?  
COMMUNITY FEATURE Available for:  
✓ Carbone Cloud  
✓ Carbone On-premise  
✓ Embedded Carbone JS   v3.0+ 

## :show(text) / :elseShow(text)

If the condition is true, `:show` prints the text between parentheses and the text is passed to the next formatter, bypassing all conditional formatters (ifEQ, show, ...).

Here are some useful examples

```cdata
{
  "val2" : 2,
  "val5" : 5
}
```

```ctemplate
- val2 = {d.val2:ifGT(3):show('high')}
- val5 = {d.val5:ifGT(3):show('high')}
- val2 = {d.val2:ifGT(3):show('high'):elseShow('low')}
```

```cresult
- val2 = 2
- val5 = high
- val2 = low
```

## Switch case

If the condition is not true, the value is passed to the next formatter. This allows you to easily create a switch-case structure like this:

```cdata
{
  "val1" : 1,
  "val2" : 2,
  "val3" : 3
}
```

```ctemplate
- val1 = {d.val1:ifEQ(1):show(A):ifEQ(2):show(B):elseShow(C)}
- val2 = {d.val2:ifEQ(1):show(A):ifEQ(2):show(B):elseShow(C)}
- val3 = {d.val3:ifEQ(1):show(A):ifEQ(2):show(B):elseShow(C)}
```

```cresult
- val1 = A
- val2 = B
- val3 = C
```

Syntax alternative: `{d.val1:ifEQ(1):show(A):or(d.val1):ifEQ(2):show(B):elseShow(C)}`

Get inspired by one of our real-life examples: [Check-out](/examples/check-out/index.md) or [EditorJS JSON output from HTML WYSIWYG Tool to PDF document](/examples/editorjs/index.md)

## With array filters

Array filter can be used to show or hide a Carbone tag. Carbone hides only one tag if the condition is not repeated for all tags in the loop.

```cdata
[
  { "name": "John", "age": 20 },
  { "name": "Eva", "age": 18 },
  { "name": "Bob", "age": 25 },
  { "name": "Charly", "age": 30 }
]
```

**Template:**

| People |
| --- |
| {d[i].name}: {d[i, age > 19].age} |
| {d[i+1].name} |

**Result:**

| People |
| --- |
| John: 20 |
| Eva: |
| Bob: 25 |
| Charly: 30 |

Get inspired by one of our real-life examples: [Planning with subtotals](/examples/planification-medium/index.md)

## :ifEmpty(textIfTrue, continueOnSuccess)

v0.12.5+

Test if data is empty (null, undefined, \[\], {}, ...).

The new formatter `:ifEM:show` should be used instead of this one.

| Params | Description | Type |
| --- | --- | --- |
| textIfTrue | textIfTrue to print if JSON data is empty | String |
| continueOnSuccess | \[optional\], if true, next formatter will be called even if the condition is true | Boolean |

_Examples_

```javascript
{d.value:ifEmpty('D'oh!')} // input: null → output: "D'oh!"
{d.value:ifEmpty('D'oh!')} // input: [] → output: "D'oh!"
{d.value:ifEmpty('D'oh!')} // input: {} → output: "D'oh!"
{d.value:ifEmpty('D'oh!')} // input: "" → output: "D'oh!"
{d.value:ifEmpty('D'oh!')} // input: 0 → output: 0
{d.value:ifEmpty('D'oh!')} // input: "homer" → output: "homer"
{d.value:ifEmpty('D'oh!')} // input: [23] → output: [23]
{d.value:ifEmpty('D'oh!')} // input: {"id":3} → output: {"id":3}
```

## :ifEqual(value, textIfTrue, continueOnSuccess)

v0.13.0+

Test if a value equals a variable.

The new formatter `:ifEQ:show` should be used instead of this one.

| Params | Description | Type |
| --- | --- | --- |
| value | value to test | String, Integer, Boolean |
| textIfTrue | message to print if the value equals JSON data | String |
| continueOnSuccess | \[optional\], if true, next formatter will be called even if the condition is true | Boolean |

_Examples_

```javascript
{d.value:ifEqual(100, 'bingo')} // input: 100 → output: "bingo"
{d.value:ifEqual(101, 'bingo')} // input: 100 → output: 100
{d.value:ifEqual('homer', 'bingo')} // input: "homer" → output: "bingo"
{d.value:ifEqual('bart', 'bingo')} // input: "homer" → output: "homer"
{d.value:ifEqual('', 'bingo')} // input: "" → output: "bingo"
{d.value:ifEqual(100, 'bingo')} // input: null → output: null
{d.value:ifEqual(null, 'bingo')} // input: null → output: "bingo"
{d.value:ifEqual(100, 'bingo')} // input: 0 → output: 0
```

## :ifContain(value, textIfTrue, continueOnSuccess)

v0.13.0+

Test if a string or an array contains a value.

The new formatter `:ifIN:show` should be used instead of this one.

| Params | Description | Type |
| --- | --- | --- |
| value | value to search | String, Integer, Boolean |
| textIfTrue | message to print if JSON data contains the value | String |
| continueOnSuccess | \[optional\], if true, next formatter will be called even if the condition is true | Boolean |

_Examples_

```javascript
{d.value:ifContain('beauti', 'bingo')} // input: "your beautiful eyes" → output: "bingo"
{d.value:ifContain('leg', 'bingo')} // input: "your beautiful eyes" → output: "your beautiful eyes"
{d.value:ifContain('eyes', 'bingo')} // input: "your beautiful eyes" → output: "bingo"
{d.value:ifContain('eyes', 'bingo')} // input: "" → output: ""
{d.value:ifContain('', 'bingo')} // input: "your beautiful eyes" → output: "bingo"
{d.value:ifContain(120, 'bingo')} // input: [100,120,20] → output: "bingo"
{d.value:ifContain(99, 'bingo')} // input: [100,120,20] → output: [100,120,20]
{d.value:ifContain('eyes', 'bingo')} // input: ["your","eyes"] → output: "bingo"
{d.value:ifContain('eyes', 'bingo')} // input: [] → output: []
```

## Related topics

- [Smart conditional blocks](/documentation/design/conditions/smart-conditions.md)
- [Conditions](/documentation/design/conditions/overview.md)
- [Conditional blocks](/documentation/design/conditions/conditional-blocks.md)
