# ReportingCloud: Conditional Text Blocks Based on Merge Blocks

> Conditional text rendering in ReportingCloud uses merge blocks combined with the RemoveEmptyBlocks setting. When the data source provides an empty object for a named block and RemoveEmptyBlocks is set to true, the complete block is stripped from the merged document output.

- **Author:** Bjoern Meyer
- **Published:** 2016-11-02
- **Modified:** 2026-07-17
- **Description:** Conditional text rendering in ReportingCloud uses merge blocks combined with the RemoveEmptyBlocks setting. When the data source provides an empty object for a named block and RemoveEmptyBlocks is set to true, the complete block is stripped from the merged document output.
- **2 min read** (281 words)
- **Tags:**
  - Cloud
  - Mail Merge
  - Reporting
  - ReportingCloud
- **Web URL:** https://www.textcontrol.com/blog/2016/11/02/reportingcloud-conditional-text-blocks-based-on-merge-blocks/
- **LLMs URL:** https://www.textcontrol.com/blog/2016/11/02/reportingcloud-conditional-text-blocks-based-on-merge-blocks/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2016/11/02/reportingcloud-conditional-text-blocks-based-on-merge-blocks/llms-full.txt

---

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*:

![ReportingCloud: Conditional text blocks based on merge blocks](https://s1-www.textcontrol.com/assets/dist/blog/2016/11/02/a/assets/template.webp "ReportingCloud: Conditional text blocks based on merge blocks")Consider, we have the following classes as the data source in C# .NET:

```
public class Report
{
    public string name { get; set; }
    public Conditional conditional { get; set; }
}

public class Conditional
{
    public string test { get; set; }
}
```

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](https://www.reporting.cloud) *MergeBody*, the *RemoveEmptyBlocks* property is set to *true*.

```
Report report = new Report();
report.name = "Name";
report.conditional = new Conditional();

ReportingCloud rc = new ReportingCloud("username", "password");

MergeBody body = new MergeBody();
body.MergeData = report;
body.MergeSettings = new MergeSettings() {
    RemoveEmptyBlocks = true
};

List<byte[]> docs = rc.MergeDocument(body, "conditional_template.tx", ReturnFormat.TX);
```

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:

![ReportingCloud: Conditional text blocks based on merge blocks](https://s1-www.textcontrol.com/assets/dist/blog/2016/11/02/a/assets/ani_template.webp "ReportingCloud: Conditional text blocks based on merge blocks")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.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [ReportingCloud: Uploading Templates Vs. Sending Templates Inside MergeBody](https://www.textcontrol.com/blog/2017/08/02/reportingcloud-uploading-templates-vs-sending-templates-inside-mergebody/llms.txt)
- [MailMerge: Table Headers and Repeating Blocks](https://www.textcontrol.com/blog/2017/08/01/mailmerge-table-headers-and-repeating-blocks/llms.txt)
- [Web API Test Sandbox Released on ReportingCloud Portal](https://www.textcontrol.com/blog/2016/10/07/web-api-test-sandbox-released-on-reportingcloud-portal/llms.txt)
- [ReportingCloud: New Test Parameter for Document Quota Related Endpoints](https://www.textcontrol.com/blog/2016/10/06/reportingcloud-new-test-parameter-for-document-quota-related-endpoints/llms.txt)
- [ReportingCloud: The MergeData JSON Object Format Explained](https://www.textcontrol.com/blog/2016/10/04/reportingcloud-the-mergedata-json-object-format-explained/llms.txt)
- [Creating Dynamic HTML Forms Using ReportingCloud](https://www.textcontrol.com/blog/2016/09/28/creating-dynamic-html-forms-using-reportingcloud/llms.txt)
- [MailMerge: Starting Each Merge Block on a New Page](https://www.textcontrol.com/blog/2016/09/09/mailmerge-starting-each-merge-block-on-a-new-page/llms.txt)
- [Creating Reports from QuickBooks or Salesforce Data Sources Using ReportingCloud and CData Cloud Drivers](https://www.textcontrol.com/blog/2016/06/30/creating-reports-from-quickbooks-or-salesforce-data-sources-using-reportingcloud-and-cdata-cloud-drivers/llms.txt)
- [ReportingCloud Monthly Payment Available](https://www.textcontrol.com/blog/2018/09/18/reportingcloud-monthly-payment-available/llms.txt)
- [Different Ways to Create Documents using Text Control Products](https://www.textcontrol.com/blog/2017/10/17/ways-to-create-documents-using-text-control-products/llms.txt)
- [Proofing Tools Available As ReportingCloud Web API Endpoints](https://www.textcontrol.com/blog/2017/08/23/proofing-tools-available-as-reportingcloud-web-api-endpoints/llms.txt)
- [All Google Fonts Now Available in ReportingCloud](https://www.textcontrol.com/blog/2017/08/22/all-google-fonts-now-available-in-reportingcloud/llms.txt)
- [New ReportingCloud MergeSettings Option: Merge HTML Content into Merge Fields](https://www.textcontrol.com/blog/2017/08/21/new-reportingcloud-mergesettings-option-merge-html-content-into-merge-fields/llms.txt)
- [Retrieving Template Information Using the ReportingCloud Web API](https://www.textcontrol.com/blog/2017/08/11/retrieving-template-information-using-the-reportingcloud-web-api/llms.txt)
- [Merging Nested Repeating Blocks in ReportingCloud](https://www.textcontrol.com/blog/2017/08/10/merging-nested-repeating-blocks-in-reportingcloud/llms.txt)
- [More Impressions from DWX Developer Week 2017](https://www.textcontrol.com/blog/2017/06/29/more-impressions-from-dwx-developer-week-2017/llms.txt)
- [DWX Developer Week 2017: First Impressions](https://www.textcontrol.com/blog/2017/06/27/dwx-developer-week-2017-first-impressions/llms.txt)
- [NDC Oslo 2017 Impressions: Part II](https://www.textcontrol.com/blog/2017/06/19/ndc-oslo-2017-impressions-part-ii/llms.txt)
- [First Day at NDC Oslo 2017: Some Impressions](https://www.textcontrol.com/blog/2017/06/15/first-day-at-ndc-oslo-2017-some-impressions/llms.txt)
- [Impressions from DevIntersection Spring in Orlando, FL](https://www.textcontrol.com/blog/2017/05/23/impressions-from-devintersection-spring-in-orlando-fl/llms.txt)
- [Impressions from Magdeburger Developer Days 2017](https://www.textcontrol.com/blog/2017/05/15/impressions-from-magdeburger-developer-days-2017/llms.txt)
- [Impressions from Dotnet Cologne 2017](https://www.textcontrol.com/blog/2017/05/08/impressions-from-dotnet-cologne-2017/llms.txt)
- [New ASP.NET MVC DocumentViewer Rolled out to the ReportingCloud Portal](https://www.textcontrol.com/blog/2017/04/22/new-aspnet-mvc-documentviewer-rolled-out-to-the-reportingcloud-portal/llms.txt)
- [New ReportingCloud Endpoint: List Available Fonts](https://www.textcontrol.com/blog/2017/03/29/new-reportingcloud-endpoint-list-available-fonts/llms.txt)
- [Introducing Groups for ReportingCloud Extreme Users](https://www.textcontrol.com/blog/2017/03/17/introducing-groups-for-reportingcloud-extreme-users/llms.txt)
