chiark / gitweb /
Documentation + comments re recent disorder-playrtp changes.
[disorder] / doc / disorder_templates.5.head
... / ...
CommitLineData
1.\"
2.\" Copyright (C) 2008 Richard Kettlewell
3.\"
4.\" This program is free software: you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation, either version 3 of the License, or
7.\" (at your option) any later version.
8.\"
9.\" This program is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16.\"
17.TH disorder_templates 5
18.SH NAME
19disorder_templates - DisOrder template file syntax
20.SH DESCRIPTION
21DisOrder template files are text files containing HTML documents, with an
22expansion syntax to enable data supplied by the implementation to be inserted.
23.SS "Expansion Syntax"
24An expansion starts with an at ("@") symbol and takes the form of an expansion
25name followed by zero or more arguments.
26.PP
27Expansion names may contain letters, digits or "-" (and must start with a
28letter or digit).
29No spacing is allowed between the "@" and the expansion name.
30.PP
31Each argument is bracketed
32Any of "(" and ")", "[" and "]" or "{" and "}" may be used but all arguments
33for a given expansion must use the same bracket pair.
34.PP
35Arguments may be separated from one another and the expansion name by
36whitespace (including newlines and even completely blank lines).
37The parser always reads as many arguments as are available, even if that is
38more than the expansion name can accept (so if an expansion is to be followed
39by an open bracket of the same kind it uses, you must use the \fB@_\fR
40separator; see below).
41.PP
42Arguments are expanded within themselves following the same rules, with a few
43exceptions discussed below.
44.SS "Special Symbols"
45A few sequences are special:
46.TP
47.B @@
48This expands to a single "@" sign.
49.TP
50.B @#
51This expands to nothing, and moreover removes the rest of the line it appears
52on and its trailing newline.
53It is intended to be used as a comment market but can also be used to eliminate
54newlines introduced merely to keep lines short.
55.TP
56.B @_
57This expands to nothing (but does not have the line-eating behaviour of
58\fB@#\fR).
59It is intended to be used to mark the end of an expansion where that would
60otherwise be ambiguous.
61.SS "Macros"
62It is possible to define new expansions using the \fB@define\fR expansion. For
63example,
64.PP
65.nf
66@define{reverse}{a b}{@b @a}
67.fi
68.PP
69defines an expansion called \fB@reverse\fR which expands to its two arguments
70in reversed order.
71The input \fB@reverse{this}{that}\fR would therefore expand to "that this".
72.SS "Sub-Expansions"
73Many expansions expand their argument with additional expansions defined.
74For example, the \fB@playing\fR expansion expands its argument with the extra
75expansion \fB@id\fR defined as the ID of the playing track.
76.PP
77The scope of these sub-expansions is purely lexical.
78Therefore if you invoke a macro or include another template file, if the
79sub-expansions appear within it they will not be expanded.
80.PP
81In the case of a macro you can work around this by passing the value as an
82argument.
83Included files do not have arguments, so in this case you must rewrite the
84inclusion as a macro.
85.SS "Search Path"
86All template files are first searched for in \fIpkgconfdir\fR and then in
87\fIpkgdatadir\fR.
88.SS "macros.tmpl and user.tmpl"
89Before any template is expanded, the CGI will process \fBmacros.tmpl\fR and
90discard any output.
91This defines a collection of commonly used macros.
92.PP
93Following this the CGI will process \fBuser.tmpl\fR, again discarding output.
94This can be used to override the common macros without editing the installed
95version of \fBmacros.tmpl\fR, or to define new ones.
96.PP
97It is not an error if \fBuser.tmpl\fR does not exist.
98.SS "Character Encoding"
99The CGI does not (currently) declare any character encoding.
100This could be changed quite easily but in practice is not a pressing necessity.
101.PP
102The recommended approach is to treat the templates as ASCII files and if
103non-ASCII characters are required, use HTML entities to represent them.
104.PP
105For example, to represent the copyright sign, use \fB&copy;\fR or \fB&#xA9;\fR.
106.PP
107If you know the decimal or hex unicode value for a character then you can use
108\fB&#NNN;\fR or \fB&#xHHHH;\fR respectively.
109.SH EXPANSIONS
110.\" Local Variables:
111.\" mode:nroff
112.\" fill-column:79
113.\" End:
114