# Liquid Playground

The Liquid Field Manipulator is specific to running in ImpulseSync, so there may be times where an external Liquid playground will not work to test the Liquid template needed. However, when viewing the configuration for a Liquid Field Manipulator you can access the ImpulseSync Liquid playground.&#x20;

## Using the ImpulseSync Liquid playground

First start by configuring or viewing the configuration for a Liquid Field Manipulator. Then press the "Test Liquid Template" button below the "Fieldvalue" config option.&#x20;

<figure><img src="https://651785290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnLYwCtfZtrK4s43AVzb4%2Fuploads%2Fsdg9Jy5z9WOwX3cbvNXU%2Fimage.png?alt=media&#x26;token=15b655ed-2ced-4f40-a747-b3f6beed7ec9" alt=""><figcaption></figcaption></figure>

This will open the ImpulseSync Liquid playground.&#x20;

<figure><img src="https://651785290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnLYwCtfZtrK4s43AVzb4%2Fuploads%2FuA2n9q8iGQ5YHHh7ppR9%2Fimage.png?alt=media&#x26;token=d73c4c65-a0c3-43d4-8e69-6c1b7d0efa37" alt=""><figcaption></figcaption></figure>

From here you can add a template and data to test the template against.&#x20;

Once the template and data have been added press the "Test Liquid Config" to test the template using the input data. The result will be displayed on the right in the JSON viewer.&#x20;

{% hint style="warning" %}
Not all Liquid tags and filters are supported in the Liquid playground. i.e., tags to retrieve additional [ImpulseSync Content objects](tags/impulse-content-objects), like categories or domains, or the [getStoredValue](filters/getstoredvalue) filter.&#x20;
{% endhint %}

### Inputting Data

The data to input is a JSON object with the following structure.&#x20;

```
[
 {
  "contentId": <string value (optional)>
  "langauge": <string value (optional)>
  "fields": [
   {
    "fieldId": <string value>
    "fieldType": <string value of Motation field types (optional)>
    "fieldValue": <string value OR array of string values OR Motation field value in debug report>
   }
  ] 
 }
]
```

#### Content ID

The contentId attribute is optional. When it's not set the ID will be a combination of "test-content-id" and the language attribute.&#x20;

#### Language

The language attribute is optional. If no language value is set, then no langauge value should be used in the Liquid template to reference fields. Akin to when a system does not support languages for content.&#x20;

#### Fields

The fields attribute is an array of field objects. This is the data to be referenced in the Liquid template.&#x20;

#### Field ID

The `fieldId` attribute is the name of the field to be used to reference the field in the Liquid template.&#x20;

#### Field Type

The `fieldType` attribute is optional. If the `fieldValue` attribute is a string or an string array then the `fieldType` will be "String" or "Array" respectively.&#x20;

If the `fieldValue` attribute is a Motation field value object, then the `fieldType` attribute can be set to any Motation field type. If it is not set, it will default to "String".&#x20;

#### Field Value

The `fieldValue` attribute is the value of the field. It can have one of the value types.&#x20;

1. string value
2. array of string values
3. Motation field value
   * Debug report uses Motation field values

{% hint style="info" %}
The [debug report's](../../../reports/debug-report#the-content-object) array of content objects at each step can be copied and pasted as the data value. Allowing for a Liquid template to be tested against the value from the debug report.&#x20;
{% endhint %}

#### Examples

**Single value**

```
[
    {
        "language": "en",
        "fields": [
            {
                "fieldId": "title",
                "fieldValue": "my content's title"
            }
        ]
    }
]
```

**Array of fields**

```
[
    {
        "language": "en",
        "fields": [
            {
                "fieldId": "title",
                "fieldValue": "my content's title"
            }, 
            {
                "fieldId": "body",
                "fieldValue": "my content's body field. \n some additional things are here"
            },
            {
                "fieldId": "number",
                "fieldValue": "7.5"
            }
        ]
    }
]
```

**Multiple string values in single field**

```
[
    {
        "language": "en",
        "fields": [
            {
                "fieldId": "title",
                "fieldValue": [
                    "first title value", 
                    "second title value", 
                    "third title value"
                ]
            }
        ]
    }
]
```

**Motation Field Value (Debug Report)**

```
[
    {
        "contentId": "entry::756f1T59Bb0LT584f9FSKF"
        "language": "en",
        "fields": [
            {
                "fieldId": "title",
                "fieldValue": [
                    {
                        "binary": {},
                        "order": 0,
                        "relations": {},
                        "value": "Benchmark Test - test"
                    }
                ]
            }
        ]
    }
]
```
