---
title: "Conditional Blocks"
canonical: "https://docs.getxray.app/space/XRAY/160039148/Conditional%20Blocks"
format: markdown
---
Conditional blocks allow you to show or hide sections of the document according to conditional expressions. 

It has the following notation:

<details>
<summary>Expand to see the sample code</summary>

```
#{if (%{<Javascript>})}
	CONTENT
#{end}

```
</details>

[<Javascript>](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301673134) is a JavaScript expression that should evaluate to true or false.

Below is a working example:

<details>
<summary>Expand to see the sample code</summary>

```
This is the header of the document. 

#{if (%{'${IssueTypeName}'.equals('Bug')})}
This section will only be visible if the issue type of the issue is Bug
This issue is a bug created by ${AssigneeUserName} with priority ${Priority}.
#{end}

#{if (%{'${Priority}'.equals('Major')})}
This section will only be visible if the priority of the issue is major.
This issue has top priority, needs to be resolved until ${DueDate}.
#{end}

#{if (%{'${escape:Description}'.equals('')})}
This issue has no description
#{end}

#{if (%{'${escape:Description}'.length > 0})}
Issue description: ${Description}
#{end}

This is the footer of the document.  
```
</details>

For more examples, check the Sample Conditions.docx template in the [Template Store](https://store.getxporter.app/).

The image below demonstrates a Word template with a conditional block:

![image](media://ae3c0a8b-4fc8-447c-8592-e4a83eb3165f)

The image below demonstrates an Excel template with a conditional block:

![image](media://52c59bb0-fc65-4301-a078-4b6542476f6b)