In several applications, it is required to render or to remove a complete text block in a template based on specific conditions. The following screenshot shows a template with a merge block (highlighted in red) that should be rendered, if the merge data contains data for this specific block with the name conditional:
Consider, we have the following classes as the data source in C# .NET:
The following code creates a new instance of the data class Report and an empty Conditional class. In the MergeSettings object, which is part of the ReportingCloud MergeBody, the RemoveEmptyBlocks property is set to true.
In case, the data for the merge block conditional is empty, the complete merge block gets removed, if RemoveEmptyBlocks is set to true. The following animation shows the result for both cases:
The logic that defines which block gets rendered or removed is not part of the template, but your data source and therefore, part of your application.