(no commit message)
[ikiwiki] / doc / recentchanges / change_53e519931f3a6b7cea0af652d749344757d4e2bc._change
1 [[!meta author="""http://jmtd.livejournal.com/"""]]
2
3 [[!meta authorurl="""http://jmtd.livejournal.com/"""]]
4
5 [[!meta title="""change to bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date on ikiwiki"""]]
6
7 [[!meta permalink="http://ikiwiki.info/recentchanges/#change-53e519931f3a6b7cea0af652d749344757d4e2bc"]]
8
9 <div id="change-53e519931f3a6b7cea0af652d749344757d4e2bc" 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/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn;h=70af505c124ac6ddb6e987c2625f92629de4690b;hp=0000000000000000000000000000000000000000;hb=53e519931f3a6b7cea0af652d749344757d4e2bc;hpb=5ecba3b05d66bb58dc48a9027838e8b0bcbc0db9" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=bugs%2Fargument_isn__39__t_numeric%3A_mixing_templates_and_creation__95__date&amp;do=goto" rel="nofollow">bugs/argument isn&#39;t numeric: mixing templates and creation&#95;date</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:23:01 -0400">10:23:01 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=53e519931f3a6b7cea0af652d749344757d4e2bc&amp;do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
32 </span>
33
34 <div class="changelog">
35
36
37 template files being treated as regular pages and the problems that can cause<br />
38
39
40 </div>
41
42 <div class="diff">
43 <pre>
44 diff --git a/doc/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn b/doc/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn
45 new file mode 100644
46 index 0000000..70af505
47 --- /dev/null
48 +++ b/doc/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn
49 @@ -0,0 +1,58 @@
50 +I get the following error when building my wiki
51 +
52 +    Argument &quot;\x{3c}\x{54}...&quot; isn&#39;t numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
53 +    Argument &quot;\x{3c}\x{54}...&quot; isn&#39;t numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
54 +
55 +that line corresponds to
56 +
57 +    sub match_creation_year ($$;@) {
58 +       if ((localtime($IkiWiki::pagectime{shift()}))&#91;5&#93; + 1900 == shift) { &lt;-- this one
59 +               return IkiWiki::SuccessReason-&gt;new(&#39;creation_year matched&#39;);
60 +       }
61 +
62 +A git bisect shows that the offending commit introduced this hunk
63 +
64 +
65 +    --- /dev/null
66 +    +++ b/templates/all_entry.mdwn
67 +    @@ -0,0 +1,23 @@
68 +    +## &lt;TMPL_VAR year&gt;
69 +    +
70 +    +There
71 +    +&lt;TMPL_IF current&gt;
72 +    +have been
73 +    +&lt;TMPL_ELSE&gt;
74 +    +were
75 +    +&lt;/TMPL_IF&gt;
76 +    +&#91;&#91;!pagecount pages=&quot;
77 +    +log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
78 +    +and creation_year(&lt;TMPL_VAR year&gt;)
79 +    +and !*.png and !*.jpg
80 +    +&quot;&#93;&#93; posts
81 +    +&lt;TMPL_IF current&gt;
82 +    +so far
83 +    +&lt;/TMPL_IF&gt;
84 +    +in &lt;TMPL_VAR year&gt;.
85 +    +
86 +    +&#91;&#91;!inline pages=&quot;
87 +    +    log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
88 +    +    and creation_year(&lt;TMPL_VAR year&gt;)
89 +    +    and !*.png and !*.jpg
90 +    +    &quot; archive=yes feeds=no&#93;&#93;
91 +
92 +The lines which feature creation_year(&lt;TMPL_VAR year&gt;) are most likely the culprits.  That would explain why the error was repeated twice, and would tally with the file in `templates/` being rendered, rather than the inclusionists.
93 +
94 +A workaround is to move the template outside of the srcdir into the external templates directory and include the file suffix when using it, e.g.
95 +
96 +    \&#91;&#91;!template id=all_entry.tmpl year=2010 current=true&#93;&#93;
97 +
98 +An alternative fix is to wrap the entire template inside a test to see whether the page is included or not. E.g.
99 +
100 +
101 +    \&#91;&#91;!if test=&quot;included()&quot; then=&quot;&quot;&quot;
102 +    ...template...
103 +    &quot;&quot;&quot; else=&quot;&quot;&quot;
104 +    Nothing to see here.
105 +    &quot;&quot;&quot;&#93;&#93;
106 +
107 +In fact, this is probably best practice for in-srcdir templates.  I&#39;d consider this done if the documentation for the directive suggested it. -- &#91;&#91;Jon&#93;&#93;
108
109 </pre>
110 </div>
111
112 <!-- 53e519931f3a6b7cea0af652d749344757d4e2bc -->