sorry, I'll try against master in future.
[ikiwiki] / doc / bugs / argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn
1 I get the following error when building my wiki
2
3     Argument "\x{3c}\x{54}..." isn't numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
4     Argument "\x{3c}\x{54}..." isn't numeric in numeric eq (==) at /usr/share/perl5/IkiWiki.pm line 2547.
5
6 that line corresponds to
7
8     sub match_creation_year ($$;@) {
9         if ((localtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) { <-- this one
10                 return IkiWiki::SuccessReason->new('creation_year matched');
11         }
12
13 A git bisect shows that the offending commit introduced this hunk
14
15
16     --- /dev/null
17     +++ b/templates/all_entry.mdwn
18     @@ -0,0 +1,23 @@
19     +## <TMPL_VAR year>
20     +
21     +There
22     +<TMPL_IF current>
23     +have been
24     +<TMPL_ELSE>
25     +were
26     +</TMPL_IF>
27     +[[!pagecount pages="
28     +log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
29     +and creation_year(<TMPL_VAR year>)
30     +and !*.png and !*.jpg
31     +"]] posts
32     +<TMPL_IF current>
33     +so far
34     +</TMPL_IF>
35     +in <TMPL_VAR year>.
36     +
37     +[[!inline pages="
38     +    log/* and !tagged(aggregation) and !*/Discussion and !tagged(draft)
39     +    and creation_year(<TMPL_VAR year>)
40     +    and !*.png and !*.jpg
41     +    " archive=yes feeds=no]]
42
43 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.
44
45 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.
46
47     \[[!template id=all_entry.tmpl year=2010 current=true]]
48
49 I believed (until I tested) that the [[ikiwiki/directive/if]] directive, with the `included()` test, would be an option here, E.g.
50
51     \[[!if test="included()" then="""
52     ...template...
53     """ else="""
54     Nothing to see here.
55     """]]
56
57 However this doesn't work.  I assume "included" in this context means e.g. via an `inline` or `map`, not template trans-clusion. -- [[Jon]]
58
59 > As far as I know, this bug was fixed in
60 > 4a75dee651390b79ce4ceb1d951b02e28b3ce83a on October 20th. [[done]] --[[Joey]]
61
62 >> Sorry Joey, I'll make sure to reproduce stuff against master in future. [[Jon]]