(no commit message)
[ikiwiki] / doc / recentchanges / change_da9e1ea667f82d5fca9168dbed19be08040570ff._change
1 [[!meta author="""http://jmtd.livejournal.com/"""]]
2
3 [[!meta authorurl="""http://jmtd.livejournal.com/"""]]
4
5 [[!meta title="""change to ikiwiki/directive/template on ikiwiki"""]]
6
7 [[!meta permalink="http://ikiwiki.info/recentchanges/#change-da9e1ea667f82d5fca9168dbed19be08040570ff"]]
8
9 <div id="change-da9e1ea667f82d5fca9168dbed19be08040570ff" class="metadata">
10 <span class="desc"><br />Changed pages:</span>
11 <span class="pagelinks">
12
13 <a href="http://git.ikiwiki.info/?p=ikiwiki;a=blobdiff;f=doc/ikiwiki/directive/template.mdwn;h=df391f99e0a23dd7cda85a8c29c1aef80baa707f;hp=9e3ae54dfd6209c92528ace49ad5ae2b3279d486;hb=da9e1ea667f82d5fca9168dbed19be08040570ff;hpb=53e519931f3a6b7cea0af652d749344757d4e2bc" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=ikiwiki%2Fdirective%2Ftemplate&amp;do=goto" rel="nofollow">ikiwiki/directive/template</a>
14
15
16 </span>
17 <span class="desc"><br />Changed by:</span>
18 <span class="committer">
19
20 <a href="http://jmtd.livejournal.com/" rel="nofollow">jmtd [livejournal.com]</a>
21
22 </span>
23 <span class="desc"><br />Commit type:</span>
24 <span class="committype">web</span>
25 <span class="desc"><br />Date:</span>
26 <span class="changedate"><span class="relativedate" title="Mon, 15 Nov 2010 10:28:05 -0400">10:28:05 11/15/10</span></span>
27 <span class="desc"><br /></span>
28 </div>
29
30 <span class="revert">
31 <a href="http://ikiwiki.info/ikiwiki.cgi?rev=da9e1ea667f82d5fca9168dbed19be08040570ff&amp;do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
32 </span>
33
34 <div class="changelog">
35
36
37 guard templates with the if directive where necessary<br />
38
39
40 </div>
41
42 <div class="diff">
43 <pre>
44 diff --git a/doc/ikiwiki/directive/template.mdwn b/doc/ikiwiki/directive/template.mdwn
45 index 9e3ae54..df391f9 100644
46 --- a/doc/ikiwiki/directive/template.mdwn
47 +++ b/doc/ikiwiki/directive/template.mdwn
48 @@ -60,22 +60,30 @@ few things:
49    `&lt;TMPL_IF variable&gt;text&lt;/TMPL_IF&gt;`.
50  * To use one block of text if a variable is set and a second if it&#39;s not,
51    use `&lt;TMPL_IF variable&gt;text&lt;TMPL_ELSE&gt;other text&lt;/TMPL_IF&gt;`
52 +* Each template file included in the wiki&#39;s source will also generate a regular
53 +  wiki page.  In many cases you might want to prevent some of your template
54 +  being interpreted for the regular page.  Use the &#91;&#91;if&#93;&#93; directive with the
55 +  `included()` test to guard the template code.
56  
57  Here&#39;s a sample template:
58  
59 -        &lt;span class=&quot;infobox&quot;&gt;
60 -        Name: \&#91;&#91;&lt;TMPL_VAR raw_name&gt;&#93;&#93;&lt;br /&gt;
61 -        Age: &lt;TMPL_VAR age&gt;&lt;br /&gt;
62 -        &lt;TMPL_IF color&gt;
63 -        Favorite color: &lt;TMPL_VAR color&gt;&lt;br /&gt;
64 -        &lt;TMPL_ELSE&gt;
65 -        No favorite color.&lt;br /&gt;
66 -        &lt;/TMPL_IF&gt;
67 -        &lt;TMPL_IF notes&gt;
68 -        &lt;hr /&gt;
69 -        &lt;TMPL_VAR notes&gt;
70 -        &lt;/TMPL_IF&gt;
71 -        &lt;/span&gt;
72 +        \&#91;&#91;!if test=&quot;included()&quot; then=&quot;&quot;&quot;
73 +          &lt;span class=&quot;infobox&quot;&gt;
74 +          Name: \&#91;&#91;&lt;TMPL_VAR raw_name&gt;&#93;&#93;&lt;br /&gt;
75 +          Age: &lt;TMPL_VAR age&gt;&lt;br /&gt;
76 +          &lt;TMPL_IF color&gt;
77 +            Favorite color: &lt;TMPL_VAR color&gt;&lt;br /&gt;
78 +          &lt;TMPL_ELSE&gt;
79 +            No favorite color.&lt;br /&gt;
80 +          &lt;/TMPL_IF&gt;
81 +          &lt;TMPL_IF notes&gt;
82 +            &lt;hr /&gt;
83 +            &lt;TMPL_VAR notes&gt;
84 +          &lt;/TMPL_IF&gt;
85 +          &lt;/span&gt;
86 +        &quot;&quot;&quot; else=&quot;&quot;&quot;
87 +          This is a template page.
88 +        &quot;&quot;&quot;&#93;&#93;
89  
90  The filled out template will be formatted the same as the rest of the page
91  that contains it, so you can include WikiLinks and all other forms of wiki
92
93 </pre>
94 </div>
95
96 <!-- da9e1ea667f82d5fca9168dbed19be08040570ff -->