Difference between revisions of "Help:TT Commenting"
HELP PAGE DISCUSSION CLOSE
m
 
m (1 revision)
 
(No difference)

Latest revision as of 23:21, 24 March 2013

How to create comments within Template Toolkit

Sometimes you when your TT code becomes long and arduous, you may went to add comments to your TT code to remind you of what goes on. To add comments in TT, use the pound sign #, and everything trailing the pound sign # will not be evaluated and left alone. Here is an example of commenting in TT:

[% # This IF statement checks to see if the # variable myvariable is true or not IF myvariable; 'myvariable is true!'; # Outputting normal text ELSE; 'myvariable is false!'; # Outputting normal text END; %]

The code above performs a simple test on the variable myvariable to see if it is true or not. Do not worry about what the TT code is doing for now, just note that there are two lines of comments that preceeds the TT code and two additional comments that following printing lines. They are comments that follow the pound sign #, and so are not evaluated. If the pound signs were missing in the example above, the TT code will cause an error.


One other thing to notice is that when your TT code is composed of several lines of code, we use semicolons ; to separate each line of TT code by placing it at the end of each line.


Back to Table of Contents