<?xml version="1.0" encoding="utf-8"?>
<s1 title="HelpOnVariables"><p></p>
<s2 id="Variables" title="Variables">
<p><p>Contents</p>
<ol><li>
<link anchor="V">Variables</link><ol><li>
<link anchor="P">Predefined Variables</link></li>
<li>
<link anchor="D">Defining New Variables</link></li>
<li>
<link anchor="G">Getting Variables</link><ol><li>
<link anchor="A">At Every Page Refresh</link></li>
<li>
<link anchor="W">When Saving the Page</link></li>
</ol>
</li>
</ol>
</li>
</ol>
<p> This page tells you more how you can use variables in wiki pages. This is especially helpful within <jump href="/wiki/HelpOnTemplates">templates</jump>, but also on &quot;normal&quot; wiki pages (like for signing a contribution). </p>
<p></p>
<s3 id="Predefined Variables" title="Predefined Variables">
<p>The following variables are substituted when a page is saved. <em><strong>Note that they will appear unreplaced in the preview!</strong></em> </p>
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p> <strong>Variable</strong> </p>
</td><td><p> <strong>Description</strong>                            </p>
</td><td><p> <strong>Example – markup</strong>                             </p>
</td><td><p> <strong>Example – render</strong> </p>
</td></tr><tr><td><p> @<code></code>PAGE@                             </p>
</td><td><p> Name of the page (useful for template pages) </p>
</td><td><p> <code>HelpOnPageCreation</code>                               </p>
</td><td><p> <jump href="/wiki/HelpOnPageCreation">HelpOnPageCreation</jump>     </p>
</td></tr><tr><td><p> @<code></code>TIMESTAMP@                        </p>
</td><td><p> Raw time stamp                               </p>
</td><td><p> <code>2004-08-30T06:38:05Z</code>                             </p>
</td><td><p> 2004-08-30T06:38:05Z   </p>
</td></tr><tr><td><p> @<code></code>DATE@                             </p>
</td><td><p> Current date in the system&apos;s format          </p>
</td><td><p> <code>&lt;&lt;Date(2004-08-30T06:38:05Z)&gt;&gt;</code>                   </p>
</td><td><p> 2004-08-30 </p>
</td></tr><tr><td><p> @<code></code>TIME@                             </p>
</td><td><p> Current date and time in the user&apos;s format   </p>
</td><td><p> <code>&lt;&lt;DateTime(2004-08-30T06:38:05Z)&gt;&gt;</code>               </p>
</td><td><p> 2004-08-30 06:38:05 </p>
</td></tr><tr><td><p> @<code></code>ME@                               </p>
</td><td><p> Just the user&apos;s name                         </p>
</td><td><p> <code>TheAnarcat</code>                                       </p>
</td><td><p> <jump href="/wiki/TheAnarcat" class="nonexistent">TheAnarcat</jump> </p>
</td></tr><tr><td><p> @<code></code>USERNAME@                         </p>
</td><td><p> Just the user&apos;s name (or his domain/IP)      </p>
</td><td><p> <code>TheAnarcat</code>                                       </p>
</td><td><p> <code>TheAnarcat</code> </p>
</td></tr><tr><td><p> @<code></code>USER@                             </p>
</td><td><p> Signature &quot;-- loginname&quot;                     </p>
</td><td><p> <code>-- TheAnarcat</code>                                    </p>
</td><td><p> -- <jump href="/wiki/TheAnarcat" class="nonexistent">TheAnarcat</jump> </p>
</td></tr><tr><td><p> @<code></code>SIG@                              </p>
</td><td><p> Dated Signature &quot;-- loginname date time&quot;     </p>
</td><td><p> <code>-- TheAnarcat &lt;&lt;DateTime(2004-08-30T06:38:05Z)&gt;&gt;</code> </p>
</td><td><p> -- <jump href="/wiki/TheAnarcat" class="nonexistent">TheAnarcat</jump> 2004-08-30 06:38:05 </p>
</td></tr><tr><td><p> @<code></code>EMAIL@                            </p>
</td><td><p> <code>&lt;&lt;MailTo()&gt;&gt;</code> Just the user&apos;s email address, obfuscation can be extended </p>
</td><td><p> e.g. test DOT user AT example DOT com </p>
</td><td><p> </p>
</td></tr><tr><td><p> @<code></code>MAILTO@                           </p>
</td><td><p> A fancy mailto: link with the user&apos;s data    </p>
</td><td><p> None – on public sites, better use the Mail<code></code>To macro </p>
</td><td><p> </p>
</td></tr></table><p></p>
</s3>
<s3 id="Defining New Variables" title="Defining New Variables">
<p>If the builtin variables are not enough, you can define new variables by creating a sub-page of your home page with a dictionary of variables in it.  For example, if your username is JohnDoe, you would create page <code>JohnDoe/MyDict</code> with the content like: </p>
<source><![CDATA[ VAR1:: some random text
 VAR2:: use ''any'' wiki markup]]></source><p>Then, whenever you edit a page, you can use <code>@VAR1@</code> or <code>@VAR2@</code> to expand to the text in that dictionary.  (Note that the lines in a dictionary must start with <em>exactly</em> one space.) </p>
<p></p>
</s3>
<s3 id="Getting Variables" title="Getting Variables">
<p></p>
<s4 id="At Every Page Refresh" title="At Every Page Refresh">
<p>You can use these values using the <code>GetVal</code> macro: </p>
<p></p>
<source><![CDATA[<<GetVal(WikiDict,var1)>> <<GetVal(WikiDict,var2)>> <<GetVal(WikiDict,var3)>>]]></source><p>Renders as: </p>
<p>   </p>
<p></p>
</s4>
<s4 id="When Saving the Page" title="When Saving the Page">
<p>If the variables are set on UserName/MyDict (UserName must of course be replaced as appropriate), you can get the variables when saving any page with @var1@, @var2@, ...etc. instead of the <code>GetVal</code> macro.  </p>
<p></p>

<br/>------------------------------------------------------------------------------<br/>
<p> </p>
<p>/!\ Note that data in dict pages is cached and does not require opening and parsing the page file for each access to the value. In CGI, the value is fetched from a pickle, in long running process, the pickle is loaded once and then the value is accessed from memory. </p>
<p>/!\ Note that saving template pages and using preview does <em>not</em> expand variables. Other than that, variable expansion is very global and happens anywhere on the page, including code displays, comments, processing instructions and other &quot;special&quot; areas of a page you might think are excluded. </p>
</s4></s3></s2></s1>