# Clauses

## Introduction

A **clause** represents a dynamic part of a [string](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/string-resources) 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](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/variables) 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](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/variables) 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](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/string-resources):

```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](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/string-resources) 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](https://docs.elentra.org/ejs/1.2/guide/internationalization/escl/concepts/variables) `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!
```
