Σtemplate example 1: basic variables and blocks

There are two types of variables in Sigma:

A block is considered empty if there are no local (to it) variables to substitute and the block does not contain non-empty subblocks.

Unknown variable placeholders and empty blocks are removed by default. This can be toggled in loadTemplateFile() call and there are means to manually control removal of blocks (see example 2).

1. Variable substitution

Set via setVariable(): {var1}, {var2}, {var3}.

Set via setGlobalVariable(): {glob}.

Unknown placeholders to remove: {foo}, {bar}.

2. Empty/nonempty blocks

2.1 Non-empty blocks


I am not empty, because a local variable is substituted: {var_ne_1}.
I am not empty, because I have a non-empty subblock: (subblock: {var_ne_2})

2.2 Empty blocks

I am empty, because here is no variable to substitute: {foo}.
I am not empty, because I have a local variable: {var_e_2},
but subblock is, as he has no local variable of his own: {var_e_2}, {var_e_sub_2}.
I am empty, as I have only a global variable: {var_e_3}, {glob}

3. Local/global difference

Local variables are cleared after substitution, globals are not.