# Text Composition

Generates a text string that contains values from other columns in the same row.

## Characteristics

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Consistency</strong></td><td valign="top">Automatically consistent with the other columns that are included in the value.</td></tr><tr><td valign="top"><strong>Linking</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Differential privacy</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Data-free</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for primary keys</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for unique columns</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Uses format-preserving encryption (FPE)</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Privacy ranking</strong></td><td valign="top">5</td></tr><tr><td valign="top"><strong>Generator ID (for the API)</strong></td><td valign="top"><a href="../../../api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/text-composition-textcompositiongenerator"><code>TextCompositionGenerator</code></a></td></tr></tbody></table>

## How to configure

1. In the **Template** field, provide the template to use to populate the value. The template uses [Liquid template syntax](https://liquidjs.com/filters/overview.html).
2. If [Structural data encryption](https://docs.tonic.ai/app/generation/generators-assign-config/generators-data-encryption-config) is enabled, then to use it for this column, in the advanced options section, toggle **Use data encryption process** to the on position.

## Setting up a value template

### **Adding a column to the template**

To add a column value to the template, add the column name enclosed in double braces:

`{{ COLUMN_NAME }}`

For example, to insert the value of a `FIRST_NAME` column, use `{{ FIRST_NAME }}`.

The **Available Columns** section display the list of columns that you can include in the template. To use the list to add a column:

1. Click the column name.
2. Paste the column into the field. When you paste the column, Structural automatically adds the  braces.

### **Adding filters to adjust the column value**

You can also use [Liquid filters](https://liquidjs.com/filters/overview.html) to manipulate the value. The Text Composition generator supports the following filters:

* `upcase`
* `downcase`
* `capitalize`
* `slice`
* `append`
* `prepend`
* `strip`
* `lstrip`
* `rstrip`
* `strip_newlines`
* `split`
* `first`
* `last`
* `join`
* `replace`
* `replace_first`
* `remove`
* `remove_first`
* `truncate`
* `truncatewords`

For example, you can change the capitalization or add a subset of the characters.

* Use `{{ COLUMN_NAME | downcase }}` to change the value to all lowercase.
* Use `{{ COLUMN_NAME | uppercase }}` to change the value to all uppercase.
* Use `{{ COLUMN_NAME | slice: <start number>, <number> }}` to only include `<number>` characters from the value, starting after the \<start number> character. To start with the first character, set `<start number>` to 0.

You can also combine filters. For example you can both change the case and extract a subset of the value:

* `{{ COLUMN_NAME | slice: <start number>, <number> | downcase }}`
* `{{ COLUMN_NAME | slice: <start number>, <number> | uppercase }}`

### **Example template**

The following template creates an email address based on `FIRST_NAME` and `LAST_NAME` columns:

* Uses the first character of the `FIRST_NAME` column, followed by a period and then the value of the `LAST_NAME` column.
* Changes both column values to all lowercase.
* Follows that with `@example.com`.

`{{ First_Name | slice: 0, 1 | downcase }}.{{ Last_Name | downcase }}@example.com`

When `FIRST_NAME`  is `John` and `LAST_NAME` is `Smith`, the resulting value is:

`j.smith@example.com`
