Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Chain and Macros

    Two service elements that appear in the tree from the format's syntax. They draw nothing of their own: both draw their single child unchanged. The syntax itself is described in the language reference — the sections “Chain” and “Macros” ; this page covers what these elements do in the tree.

    Chain

    A flat list of wrappers. Each next child of Chain is nested into the previous one: the first wraps the second, the second wraps the third, and the last one becomes the content. Variables declared in a link of the chain are visible to all links below it.

    Type: wrapper

    Chain
      ColoredBox color:0xFFE0E7FF
      Padding
        #padding all 16
      Center
      Text "Hello"

    The same without Chain :

    ColoredBox color:0xFFE0E7FF
      Padding
        #padding all 16
        Center
          Text "Hello"

    There are no parameters. In the parsed tree Chain stays the root of the chain: its single child is the first link, and the rest lie inside it.

    Handy where there are many wrappers and their order changes: a link's line can be moved or deleted without touching the indentation of the others.

    Macros

    The element a macro call $Name becomes in the tree. It holds the call's parameters as variables (the macro body reads them through $ ) and draws the expanded macro body. The row template @Macros id:… of lists and Repeat is written with the same name: every expanded row is an instance of the same kind.

    Type: wrapper

    @Badge label:""
      Container
        #padding all 8
        #decoration color:0xFFE0E7FF
          #borderRadius circular 8
        Text $label
    
    Row spacing:8
      $Badge label:"New"
      $Badge label:"−20 %"

    The element itself has no parameters: everything passed to the call ( label:"New" ) becomes a variable of that instance. The @Badge declaration does not get into the tree — only instances do.

    A template without a macro name is @Macros with default parameters: its parent expands it, substituting its own values ( index is the row number):

    State @names:["Anna", "Boris"]
      Column
        Repeat count:{length(names)}
          @Macros id:itemBuilder index:0
            Text {names[index]}

    Under @Macros there is exactly one direct child; wrap several elements in a Column or Row .

    How many elements macro expansion may copy is covered in “Macro expansion limit” .

    Differences between the app and the site

    None: on the site both elements are transparent and draw only their content, as in the app.

    See also