Updated on 2022-02-22 GMT+08:00

Variable Reference

During template compilation, you can reference a defined variable or reference a member variable of another object, just like the variable reference during function compilation. You can also reference other existing values in an AOS template.

To ease template compilation, different reference methods are used based on the reference objects:

The preceding reference methods are also called built-in functions. In addition to reference functions, built-in functions also include many other functions. For more information, see Table 1.

Table 1 AOS built-in functions

Built-In Function

Description

get_input

Used to obtain the values of input parameters in the inputs section of the template file.

get_attribute

Used to obtain the initialization results of other elements in the template.

get_reference

Simplified form of the get_attribute function. When the attribute information ends with id or name, use the get_attribute (refID or refName) function.

get_in_map

Used to obtain the content in mapping tables.

Condition function

Used to define whether elements need to be deployed, including cond_eq, cond_not, cond_and, cond_or, and cond_if.

base64_encode

Used to encode character strings in base64 mode.

concat

Used to convert description fields into strings and concatenate them. It can be embedded with the get_attribute and get_input functions.

split

Used together with the select/get_list_length function in most cases. The split function is mainly used in the following scenarios:

  • A string is split into a group of strings so that specific elements can be easily obtained from the result string list.
  • A result string array is directly used.

select

Used to obtain the object with a specified subscript from an array structure. Generally, this function is used together with the split function.

get_list_length

Used to calculate the number of elements in an array structure. Generally, this function is used together with the split function.