# Clauses

## Introduction

A **clause** represents a dynamic part of a [string](/ejs/1.3/guide/internationalization/escl/concepts/string-resources.md) that will be processed.  Clauses are the backbone of ESCL, as everything happens inside a clause.

## Working with clauses

You represent a clause in a string using brace brackets.  This clause contains a single [variable](/ejs/1.3/guide/internationalization/escl/concepts/variables.md) named `firstName`.

```javascript
`{ :firstName }`
```

You'll also notice that there is a space after the opening brace and before the closing brace.  These extra padding spaces are intentionally enforced to ensure clause readability.  Like the braces, they are not considered during processing.

## Spaces in clauses

While the padding spaces mentioned above are not considered during processing, all other spaces are considered.  This clause contains two [variables](/ejs/1.3/guide/internationalization/escl/concepts/variables.md) with a space separating them:

```javascript
`Hello, { :firstName :lastName }, and welcome!`
```

Assuming we pass in the appropriate variable values for John Doe, this will output:

```
Hello, John Doe, and welcome!
```

Notice the space between the variables is respected but the padding spaces are not.

## Multiple clauses

You may also include multiple clauses in a single [string](/ejs/1.3/guide/internationalization/escl/concepts/string-resources.md):

```javascript
`Hello, { :firstName :lastName }, and welcome to { :appName }!`
```

## Recursive clauses

When processing a clause, a recursive object graph is generated to represent the clause itself, the tokens it contains, and whether those tokens reference other [strings](/ejs/1.3/guide/internationalization/escl/concepts/string-resources.md) which themselves contain clauses.

Using this object graph, ESCL is able to support advanced string composition functionality at depth and simplifies its usage in an application.

In this example, we build the `welcome_message` string with a clause which references the `user_display_name` string, and a clause with its own [variable](/ejs/1.3/guide/internationalization/escl/concepts/variables.md) `appName`:

```javascript
user_display_name: `{ :firstName :lastName }`,
welcome_message: `Hello, { user_display_name }, and welcome to { :appName }!`
```

Thanks to clause recursion, we can use `welcome_message` and pass in the `firstName` and `lastName` variables, as though they were defined in the string itself:

```javascript
$translate('welcome_message', { 
    firstName: 'John',
    lastName: 'Doe',
    appName: 'EJS'
});

Outputs: 
Hello, John Doe, and welcome to EJS!
```


---

# 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://docs.elentra.org/ejs/1.3/guide/internationalization/escl/concepts/clauses.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.
