Using STJ

All configuration of StackState is described using StackState Template JSON (STJ).

This page describes StackState version 4.3.

The StackState 4.3 version range is End of Life (EOL) and no longer supported. We encourage customers still running the 4.3 version range to upgrade to a more recent release.

Go to the documentation for the latest StackState release.

Overview

StackState's graph is entirely configured using JSON. To make it easy to work with large quantities of (often repetitive) JSON, StackState comes with the StackState Template JSON format (STJ).

STJ is based on handlebars (handlebarsjs.com) and comes with a number of StackState functions.

Handlebars syntax

StackState template files use handlebars. Content that is placed between double curly brackets {{ some content }} is included in the output. The example below shows handlebars used in a component template:

[{
  "_type": "Component",
  "checks": [],
  "streams": [],
  "labels": [],
  "name": "{{ name }}",
  "description": "{{ description }}",
  "type" : {{ componentTypeId }},
  "layer": {{ layerId }},
  "domain": {{ domainId }},
  "environments": [{{ environmentId }}]
}]

Conditionals: #if / else

Run some template code conditionally if a variable has a value.

{{# if description }}
"description": "{{ description }}",
{{else}}
"description": "noop",
{{/ if }}

Looping: #each

Loop over an array or map of data.

[
  {{# each names }}
  "hello {{this}}",
  {{/ each }}
  "bye y'all!"
]

StackState Functions

StackState adds a number of function to the handlebars syntax. You can use these to create complex JSON results.

Please have a look at the available functions.

Component and Relation templates

Templates are used to create topology. Please find more information on the Component and Relation templates page..

See also

Last updated