StyleBook configuration

Variable reference

When you use the repeat and repeat-item constructs in components to build multiple configuration objects, you can assign a variable name to the repeat-item construct. This variable can be then referenced in the properties of that component or in child components by using the notation $<varname>. Note that when the repeat construct is used without the repeat-item construct in a component, a default variable called $repeat-item can be used to access the iteration items.

Example:

components:

  -

    name: server-members-comp

    type: ns::server

    condition: $parameters.svc-server-domain-names

    repeat: $parameters.svc-server-domain-names

    repeat-item: server-name

    properties:

      name: $server-name + "-server"

      domain: $server-name

    components:

      -

         name: service-members-comp

         type: ns::service

         properties:

           name: $server-name + "-service"

           servername: $parent.properties.name

           servicetype: $parameters.svc-service-type

           port: $parameters.svc-server-port
<!--NeedCopy-->

In the above example, a variable name, server-name, is assigned to the repeat-item construct. This variable name is referred to in the properties of the same component and in the child components $<varname>.

Variable reference

In this article