]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/argument_isn__39__t_numeric:_mixing_templates_and_creation__95__date.mdwn
5485bba9ca2244260ae4ecb0894e935817bf377d
[ikiwiki.git] / 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 An alternative fix is to wrap the entire template inside a test to see whether the page is included or not. E.g.
50
51
52     \[[!if test="included()" then="""
53     ...template...
54     """ else="""
55     Nothing to see here.
56     """]]
57
58 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]]
59
60 > [[done]] with <http://git.ikiwiki.info/?p=ikiwiki;a=commitdiff;h=da9e1ea667f82d5fca9168dbed19be08040570ff> -- [[Jon]]