​Templates

​Using Placeholders in Templates

Jedison allows you to define templates with dynamic titles and descriptions that use placeholders. These placeholders are replaced at runtime with relevant values.

​Available Placeholders

  • value — The current value (from getValue()); always available
  • settings — Configuration options (from jedison.options.settings); always available
  • i0 — The zero-based index of the array item; available only if the editor is an array item editor
  • i1 — The one-based index of the array item; available only if the editor is an array item editor
  • parent — Parent instance template data; available when parent exists
  • length — The length of the string value; available only for string types
  • remaining — Characters remaining (maxLength - length); available only for strings with maxLength

​Fallback Values

Use the || operator inside a placeholder to provide a fallback value when the placeholder resolves to null or undefined:

{{ value.name || 'Unnamed' }}

The fallback can be any quoted string (single or double quotes). When the placeholder has a value, the fallback is ignored.

​Example

{
  "title": "Team Members",
  "type": "array",
  "x-format": "nav-vertical",
  "x-titleTemplate": "{{ value.name || 'Unnamed' }}",
  "minItems": 2,
  "default": [
    {
      "name": "Alice"
    },
    {}
  ],
  "items": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "title": "Name"
      }
    }
  }
}

​Parent Template Access

When working with nested structures, you can access parent instance data using the parent placeholder. This is particularly useful for creating hierarchical titles and references.

​Common Parent Access Patterns

  • parent.value — Access the parent's current value
  • parent.i1 — Access the parent's array index (1-based)
  • parent.parent.value — Access grandparent's value (for deeply nested structures)

​Example

{
  "title": "Templates",
  "type": "array",
  "x-format": "nav-vertical",
  "minItems": 1,
  "default": [
    {
      "name": "Tech Corp",
      "departments": [
        {
          "name": "Engineering"
        }
      ]
    }
  ],
  "x-titleTemplate": "{{ value.name }}",
  "items": {
    "title": "Company {{ i1 }} - {{ value.name }}",
    "description": "Company {{ i1 }} has name: {{ value.name }}",
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "title": "Company Name",
        "default": "New Company"
      },
      "departments": {
        "type": "array",
        "title": "Departments",
        "x-format": "nav-vertical",
        "minItems": 1,
        "default": [
          {
            "name": "General"
          }
        ],
        "x-titleTemplate": "{{ parent.parent.value.name }} - {{ value.name }}",
        "items": {
          "title": "{{ parent.parent.value.name }} - {{ value.name }}",
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "title": "Department Name",
              "default": "New Department"
            }
          }
        }
      }
    }
  }
}