1 [[!meta author="""http://jmtd.livejournal.com/"""]]
3 [[!meta authorurl="""http://jmtd.livejournal.com/"""]]
5 [[!meta title="""change to bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date on ikiwiki"""]]
7 [[!meta permalink="http://ikiwiki.info/recentchanges/#change-53e519931f3a6b7cea0af652d749344757d4e2bc"]]
9 <div id="change-53e519931f3a6b7cea0af652d749344757d4e2bc" class="metadata">
10 <span class="desc"><br />Changed pages:</span>
11 <span class="pagelinks">
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&do=goto" rel="nofollow">bugs/argument isn't numeric: mixing templates and creation_date</a>
17 <span class="desc"><br />Changed by:</span>
18 <span class="committer">
20 <a href="http://jmtd.livejournal.com/" rel="nofollow">jmtd [livejournal.com]</a>
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>
31 <a href="http://ikiwiki.info/ikiwiki.cgi?rev=53e519931f3a6b7cea0af652d749344757d4e2bc&do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
34 <div class="changelog">
37 template files being treated as regular pages and the problems that can cause<br />
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
46 index 0000000..70af505
48 +++ b/doc/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn
50 +I get the following error when building my wiki
52 + Argument "\x{3c}\x{54}..." isn't numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
53 + Argument "\x{3c}\x{54}..." isn't numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
55 +that line corresponds to
57 + sub match_creation_year ($$;@) {
58 + if ((localtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) { <-- this one
59 + return IkiWiki::SuccessReason->new('creation_year matched');
62 +A git bisect shows that the offending commit introduced this hunk
66 + +++ b/templates/all_entry.mdwn
68 + +## <TMPL_VAR year>
71 + +<TMPL_IF current>
76 + +[[!pagecount pages="
77 + +log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
78 + +and creation_year(<TMPL_VAR year>)
79 + +and !*.png and !*.jpg
80 + +"]] posts
81 + +<TMPL_IF current>
84 + +in <TMPL_VAR year>.
86 + +[[!inline pages="
87 + + log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
88 + + and creation_year(<TMPL_VAR year>)
89 + + and !*.png and !*.jpg
90 + + " archive=yes feeds=no]]
92 +The lines which feature creation_year(<TMPL_VAR year>) 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.
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.
96 + \[[!template id=all_entry.tmpl year=2010 current=true]]
98 +An alternative fix is to wrap the entire template inside a test to see whether the page is included or not. E.g.
101 + \[[!if test="included()" then="""
103 + """ else="""
104 + Nothing to see here.
105 + """]]
107 +In fact, this is probably best practice for in-srcdir templates. I'd consider this done if the documentation for the directive suggested it. -- [[Jon]]
112 <!-- 53e519931f3a6b7cea0af652d749344757d4e2bc -->