<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Sigma example 1: basic variables and blocks</title> </head> <body> <h1>Σ<sub>template</sub> example 1: basic variables and blocks</h1> <p>There are two types of variables in Sigma:</p> <ul> <li><i>local</i> variables: these get cleared after substitution and control the empty/non-empty block logic</li> <li><i>global</i> variables: these never get cleared and do not influence block's empty status</li> </ul> <p>A block is considered empty if there are no local (to it) variables to substitute and the block does not contain non-empty subblocks.</p> <p>Unknown variable placeholders and empty blocks are removed by default. This can be toggled in <b>loadTemplateFile()</b> call and there are means to manually control removal of blocks (see example 2).</p> <h2>1. Variable substitution</h2> <p>Set via <b>setVariable()</b>: {var1}, {var2}, {var3}.</p> <p>Set via <b>setGlobalVariable()</b>: {glob}.</p> <p>Unknown placeholders to remove: {foo}, {bar}.</p> <h2>2. Empty/nonempty blocks</h2> <h3>2.1 Non-empty blocks</h3> <hr> <!-- BEGIN nonempty_1 --> I am not empty, because a local variable is substituted: {var_ne_1}. <!-- END nonempty_1 --> <hr> <!-- BEGIN nonempty_2 --> I am not empty, because I have a non-empty subblock: <!-- BEGIN subblock --> (subblock: {var_ne_2}) <!-- END subblock --> <!-- END nonempty_2 --> <h3>2.2 Empty blocks</h3> <!-- BEGIN empty_1 --> I am empty, because here is no variable to substitute: {foo}. <!-- END empty_1 --> <hr> <!-- BEGIN empty_2 --> I am not empty, because I have a local variable: {var_e_2},<br> <!-- BEGIN empty_subblock_2 --> but subblock is, as he has no local variable of his own: {var_e_2}, {var_e_sub_2}. <!-- END empty_subblock_2 --> <!-- END empty_2 --> <hr> <!-- BEGIN empty_3 --> I am empty, as I have only a global variable: {var_e_3}, {glob} <!-- END empty_3 --> <h2>3. Local/global difference</h2> <p>Local variables are cleared after substitution, globals are not.</p> <ul> <!-- BEGIN list --> <li>{local_1}, {local_2}, {glob}</li> <!-- END list --> </ul> </body> </html>