aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/template_creation_error.mdwn
blob: 79dccc136629a312f5d920e1891e712faac24a45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Hi,
I am trying to build a template. The compilation of this template results in a weird exception. I have isolated the cause of the exception to the following point:

If i have this in the template code:

\[[!inline<br/>
pages="\<TMPL_VAR SEL_PAGES\>"<br/>
template=extract-entry<br/>
\]]<br/>

There is no problem at all. I can use the template with the desired result. But if I try to use this (just adding the "show" parameter):

\[[!inline <br/>
pages="\<TMPL_VAR SEL_PAGES>"<br/>
template=extract-entry<br/>
show=\<TMPL_VAR CNTPG><br/>
\]]<br/>

I get this exception on the Git bash console:

<pre>
$ git push
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 410 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: From /home/b-odelama-com/source
remote:    eb1421e..5e1bac5  master     -> origin/master
remote: Argument "\x{3c}\x{54}..." isn't numeric in numeric lt (<) at /usr/share/perl5/IkiWiki/Plugin/inline.pm line 231.
remote: Argument "\x{3c}\x{54}..." isn't numeric in numeric lt (<) at /usr/share/perl5/IkiWiki/Plugin/inline.pm line 231.
To ssh://b-odelama-com@odelama-com.branchable.com/
   eb1421e..5e1bac5  master -> master
</pre>

Please, let me know what to do to avoid this kind of error.

> When you add a template page `templates/foo.mdwn` for use
> the [[ikiwiki/directive/template]] directive, two things happen:
>
> 1. `\[[!template id=foo ...]]` becomes available;
> 2. a wiki page `templates/foo` is built, resulting in a HTML file,
>    typically `templates/foo/index.html`
>
> The warnings you're seeing are the second of these: when ikiwiki
> tries to process `templates/foo.mdwn` as an ordinary page, without
> interpreting the `<TMPL_VAR>` directives, `inline` receives invalid
> input.
>
> This is a bit of a design flaw in [[plugins/template]] and
> [[plugins/edittemplate]], I think - ideally it would be possible to
> avoid parts of the page being interpreted when the page is being
> rendered normally rather than being used as a template.
>
> There *is* a trick to avoid parts of the page being interpreted when
> the page is being used as a template, while having them appear
> when it's rendered as a page:
>
>     <TMPL_IF FALSE>
>     <!-- This part only appears when being used as a page.
>          It assumes that you never set FALSE to a true value :-) -->
>     \[[!meta robots="noindex,nofollow"]]
>     This template is used to describe a thing. Parameters:
>     * name: the name of the thing
>     * size: the size of the thing
>     </TMPL_IF>
>
>     The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size>
>
> I suppose you could maybe extend that to something like this:
>
>     <TMPL_IF FALSE>
>     <!-- This part only appears when being used as a page.
>          It assumes that you never set FALSE to a true value :-) -->
>     \[[!meta robots="noindex,nofollow"]]
>     This template is used to describe a thing. Parameters:
>     * name: the name of the thing
>     * size: the size of the thing
>     </TMPL_IF>
>
>     <TMPL_IF FALSE>
>     \[[!if test="included() and !included()" then="""
>     </TMPL_IF>
>     <!-- This part only appears when being used as a template. It also
>          assumes that you never set FALSE to a true value, and it
>          relies on the [[ikiwiki/pagespec]] "included() and !included()"
>          never being true. -->
>     The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size>
>     <TMPL_IF FALSE>
>     """]]
>     </TMPL_IF>
>
> but that's far harder than it ought to be!
>
> Perhaps the right solution would be to change how the template plugin
> works, so that templates are expected to contain a new `definetemplate`
> directive:
>
>     This template is used to describe a thing. Parameters:
>     * name: the name of the thing
>     * size: the size of the thing
>     
>     \[[!definetemplate """
>     The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size>
>     """]]
>
> with templates not containing a `\[[!definetemplate]]` being treated
> as if the whole text of the page was copied into a `\[[!definetemplate]]`,
> for backwards compatibility?
>
> --[[smcv]]