This element ca be used to define custom values to be reused later in the attributes of other elements, in order to avoid repeating several times the same value. It makes it easier to change the value once rather than everywhere in the code.
Note: to avoid conflicts with Predefined Variables, variables starting and ending with '_' are reserved to the KUIML engine.
Attributes brief detailed show all inherited
|id||id of the variable||empty|
|value||value of the variable||empty|
|formula||The formula can reference other static variables that have been defined previously. The result of the formula is stored in the variable at the declaration of the variable and is not updated later, even if other variables it depends on are changed||empty|
|script||Script that returns a string that defines the new value of the variable. It can use functions that have been defined in the build_time_script_include file (but not other runtime function defined in runtime scripts). It can also refer to build time variables that have been defined before||empty|
|override||override previously defined value||false|
First declare a variable as shown here:
- <VARIABLE id="my_variable" value="hello world!" />
Once this variable has been declared, writing the following
is equivalent to writing:
The same example, with script syntax (note that all special characters in script have to be escaped):
- <VARIABLE id="my_variable" script="return "hello world!"" />
The possibility to "override" variables is useful in complicated layouts and templates. If you plan to use overriden variables often, then you can add defines like this to shorten the code (already defined in LM Skin):
Now you can write something like this:
The output should look like this:
You could use "LV" (LOCAL_VARIABLEs) instead, if you don't need these values later (for example a temporary variable inside a TEMPLATE).
If you need to do some complicated operations while build-time (usually related to strings) you can use scripts inside VARIABLES, like this:
However, if you use too many scripts, you may slow down skin loading time a bit. Also keep in mind, that scripts inside VARIABLEs are executed twice while build-time (for technical reasons), and that can be important if you're manipulating with something like file contents.