> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Merge transformer output

> Combines the output of a transformer with the existing data.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Runs another transformer and then blends its result back into your original data, using a template you control. Some transformers replace the whole entity, which would lose the data you started with; this transformer keeps that from happening by layering the new result on top of what was already there. Use it to capture a result, such as a computed field or a response from an external call, while keeping the rest of the entity intact.

This documentation describes: [Schema](/schemas/transformer/merger)

## Fields

<FormField property="transformer" label="Data transformer" required diType="transformer">
  The transformer to run. It runs against the current data, and its result is what gets merged back in through the template.
</FormField>

<FormField property="template" label="Template" required>
  Describes the shape that gets layered on top of your original data. Build the structure you want here, using placeholders to pull in the transformer's result: `&{some_field}` inserts a single value from it, and `&{@}` inserts its entire output. Whatever you build is merged into the original entity, so existing fields stay unless your template writes over them. See [Placeholders](/references/placeholders) for the syntax.
</FormField>

## Sample data

In this example the chosen transformer adds a `currency` field, and the template uses both the original `price` and that new `currency` to build a nested `pricing` block. The original fields are kept, and the `pricing` block is added on top.

| Field            | Value                                                                |
| ---------------- | -------------------------------------------------------------------- |
| Data transformer | Set values: `currency` = `EUR`                                       |
| Template         | `{ "pricing": { "amount": "&{price}", "currency": "&{currency}" } }` |

Input:

```json theme={null}
{
    "sku": "A-100",
    "price": 19.99
}
```

Output:

```json theme={null}
{
    "sku": "A-100",
    "price": 19.99,
    "currency": "EUR",
    "pricing": {
        "amount": 19.99,
        "currency": "EUR"
    }
}
```

```json Configuration theme={null}
{
  "prototype": "merger",
  "parameters": {
    "transformer": {
      "prototype": "value-setter",
      "parameters": {
        "configurations": [
          { "key": "currency", "value": "EUR" }
        ]
      }
    },
    "template": { "pricing": { "amount": "&{price}", "currency": "&{currency}" } }
  }
}
```
