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