# Conditional Logic Structure

## Basic Model

```
<!--RENDER='<merge field>' == '[Value]' -->
  [Conditional Content]
<!--ENDRENDER-->
```

## Complex Model

```
<!--RENDER='<merge field>' == '[Value]' -->
  This message is for an active account.
  <!--RENDER1=( ('<merge field>' == '[Value]' || '<merge field>' == '[Value]') 
               && ('<merge field>' == '[Value]' || '<merge field>' CONTAINS '[Value]') ) -->
    Special terms apply for your account based on location and contract status.
    <!--RENDER2= <merge field> <= [Value] -->
      Note: This opportunity is marked as urgent. Immediate action is recommended.
    <!--ENDRENDER2-->
    <!--RENDER2='<merge field>' != '[Value]' -->
      Dear Manager, we have tailored recommendations for your review.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

### 1. `<!--RENDER='<merge field>' == '[Value]'-->`

### Purpose

Start of a conditional block. S-Docs evaluates the expression and only renders the block if the condition is **true**.

***

### 2. `[Conditional Content]`

### Purpose

Text or sections that are included in the generated document only when the render condition evaluates to true.

***

### 3. `<!--ENDRENDER-->`

### Purpose

Closes a `RENDER` block. It must match every `RENDER` tag.

***

### 5. `==`, `!=`, `>`, `<`, `>=`, `<=`, `CONTAINS`, `NOT CONTAINS`

### Purpose

Comparison operators inside render conditions.

| Operator     | Meaning                           |
| ------------ | --------------------------------- |
| ==           | Equal                             |
| !=           | Not equal                         |
| >            | Greater than                      |
| <            | Less than                         |
| >=           | Greater than or equal             |
| <=           | Less than or equal                |
| CONTAINS     | String contains substring         |
| NOT CONTAINS | String does not contain substring |

***

### 7. `&&`, `||`, `()`

### Purpose

Used for combining multiple conditions into one render statement.

* `&&` — AND (both conditions must be true)
* `||` — OR (either condition can be true)
* `()` — Used to group multiple expressions

***

### 6. `RENDER1`, `RENDER2`, `RENDER3`

### Purpose

Nesting multiple conditions under one condition. Each nested level must have an incremented name (e.g., `RENDER1`, `RENDER2`) and be paired with a matching `ENDRENDER1`, `ENDRENDER2`, etc.

{% hint style="info" %}
Please note the following:

* Nested blocks require incremented naming (`RENDER1`, `RENDER2`, etc.). Each nested level must have a unique name.
* They must be properly paired with matching `ENDRENDER1`, etc.
* All `RENDER` tags must have a corresponding `ENDRENDER`, and nested blocks cannot skip levels.
  {% endhint %}

***

## Summary Table

| Component            | Syntax / Example                                                                                                                | Purpose / Description                                                                                                      |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| RENDER Tag           | `<!--RENDER='<merge field>' == '[Value]' -->`                                                                                   | Starts a conditional block. S-Docs evaluates the expression and renders the block only if the condition evaluates to true. |
| Conditional Content  | `[Conditional Content]`                                                                                                         | Text or sections included in the generated document only when the render condition evaluates to true.                      |
| ENDRENDER Tag        | `<!--ENDRENDER-->`                                                                                                              | Closes a `RENDER` block. Every `RENDER` must have a matching `ENDRENDER`.                                                  |
| Nested RENDER Tags   | <p><code>RENDER1</code>, <code>RENDER2</code>, <code>RENDER3</code><br><br><code>ENDRENDER1</code>, <code>ENDRENDER2</code></p> | Used for nested conditional logic inside a parent `RENDER` block. Each level represents a deeper condition.                |
| Comparison Operators | `==`, `!=`, `>`, `<`, `>=`, `<=`                                                                                                | Compare values in render conditions (equality, inequality, numeric comparisons).                                           |
| Substring Operators  | `CONTAINS`, `NOT CONTAINS`                                                                                                      | Evaluate whether a string contains (or does not contain) a specified substring.                                            |
| Logical Operators    | `&&`, `\|`                                                                                                                      | Combines multiple conditions.                                                                                              |
| Parentheses          | `( )`                                                                                                                           | Groups multiple expressions to control evaluation order in complex conditions.                                             |

## Full Example

```
<!--RENDER=( '{{!Account.Active__c}}' == 'True' ) -->
  This message is for an active account.
  <!--RENDER=( ('{{!Account.BillingState}}' == 'CA' || '{{!Account.BillingState}}' == 'NY') 
               && ('{{!Account.Contract_Type__c}}' == 'Premium' || '{{!Account.Name}}' CONTAINS 'Enterprise') ) -->
    Special terms apply for your account based on location and contract status.
    <!--RENDER='{{!Opportunity.Description}}' CONTAINS 'Urgent' -->
      Note: This opportunity is marked as urgent. Immediate action is recommended.
    <!--ENDRENDER-->
    <!--RENDER1='{{!Contact.Title}}' CONTAINS 'Manager' -->
      Dear Manager, we have tailored recommendations for your review.
    <!--ENDRENDER1-->
  <!--ENDRENDER-->
<!--ENDRENDER-->
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/developer-hub/template-configuration-and-styling/conditional-logic-reference/conditional-logic-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
