Blame


1 6509b181 2022-12-30 thomas .\" Copyright (c) 2022 Omar Polo <op@openbsd.org>
2 6509b181 2022-12-30 thomas .\"
3 6509b181 2022-12-30 thomas .\" Permission to use, copy, modify, and distribute this software for any
4 6509b181 2022-12-30 thomas .\" purpose with or without fee is hereby granted, provided that the above
5 6509b181 2022-12-30 thomas .\" copyright notice and this permission notice appear in all copies.
6 6509b181 2022-12-30 thomas .\"
7 6509b181 2022-12-30 thomas .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 6509b181 2022-12-30 thomas .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 6509b181 2022-12-30 thomas .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 6509b181 2022-12-30 thomas .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 6509b181 2022-12-30 thomas .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 6509b181 2022-12-30 thomas .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 6509b181 2022-12-30 thomas .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 6509b181 2022-12-30 thomas .\"
15 10125703 2024-03-30 thomas .Dd January 6, 2022
16 6509b181 2022-12-30 thomas .Dt TEMPLATE 1
17 6509b181 2022-12-30 thomas .Os
18 6509b181 2022-12-30 thomas .Sh NAME
19 6509b181 2022-12-30 thomas .Nm template
20 6509b181 2022-12-30 thomas .Nd templating system compiler
21 6509b181 2022-12-30 thomas .Sh SYNOPSIS
22 6509b181 2022-12-30 thomas .Nm
23 6509b181 2022-12-30 thomas .Op Fl G
24 6509b181 2022-12-30 thomas .Op Fl o Ar out
25 6509b181 2022-12-30 thomas .Op Ar
26 6509b181 2022-12-30 thomas .Sh DESCRIPTION
27 6509b181 2022-12-30 thomas .Nm
28 6509b181 2022-12-30 thomas is an utility that converts files written in the
29 6509b181 2022-12-30 thomas .Xr template 7
30 6509b181 2022-12-30 thomas format format to a set of routine writtens in the C programming
31 6509b181 2022-12-30 thomas language.
32 6509b181 2022-12-30 thomas .Nm
33 6509b181 2022-12-30 thomas converts the files given as arguments or from standard input, and
34 6509b181 2022-12-30 thomas writes to standard output.
35 6509b181 2022-12-30 thomas .Pp
36 6509b181 2022-12-30 thomas The options are as follows:
37 6509b181 2022-12-30 thomas .Bl -tag -width Ds
38 6509b181 2022-12-30 thomas .It Fl G
39 6509b181 2022-12-30 thomas Do not emit debug info in the generated source.
40 6509b181 2022-12-30 thomas It's disabled by default, unless
41 6509b181 2022-12-30 thomas .Nm
42 6509b181 2022-12-30 thomas is reading from standard input.
43 6509b181 2022-12-30 thomas .It Fl o Ar out
44 6509b181 2022-12-30 thomas Write output to file.
45 6509b181 2022-12-30 thomas .Ar out
46 6509b181 2022-12-30 thomas will be created or truncated if exists and will be removed if
47 6509b181 2022-12-30 thomas .Nm
48 6509b181 2022-12-30 thomas encounters any error.
49 6509b181 2022-12-30 thomas .El
50 6509b181 2022-12-30 thomas .Sh EXIT STATUS
51 bf92bf9b 2023-01-07 thomas .Ex -std
52 6509b181 2022-12-30 thomas .Sh SEE ALSO
53 6509b181 2022-12-30 thomas .Xr template 7
54 6509b181 2022-12-30 thomas .Sh AUTHORS
55 6509b181 2022-12-30 thomas .An -nosplit
56 6509b181 2022-12-30 thomas The
57 6509b181 2022-12-30 thomas .Nm
58 6509b181 2022-12-30 thomas utility was written by
59 6509b181 2022-12-30 thomas .An Omar Polo Aq Mt op@openbsd.org .
60 6509b181 2022-12-30 thomas .Sh CAVEATS
61 6509b181 2022-12-30 thomas The compiler is very naive, so there are quite a few shortcomings:
62 6509b181 2022-12-30 thomas .Bl -bullet -compact
63 6509b181 2022-12-30 thomas .It
64 6509b181 2022-12-30 thomas No attempt is made to validate the C code provided inline, nor the
65 6509b181 2022-12-30 thomas validity of the arguments to many constructs.
66 6509b181 2022-12-30 thomas .It
67 6509b181 2022-12-30 thomas The generated code assumes that a variable called
68 6509b181 2022-12-30 thomas .Va tp
69 6509b181 2022-12-30 thomas of type
70 6509b181 2022-12-30 thomas .Vt struct template *
71 6509b181 2022-12-30 thomas is in scope inside each block.
72 6509b181 2022-12-30 thomas .It
73 6509b181 2022-12-30 thomas Each block may have additional variables used for the template
74 6509b181 2022-12-30 thomas generation implicitly defined: to avoid clashes, don't name variables
75 6509b181 2022-12-30 thomas or arguments with the
76 6509b181 2022-12-30 thomas .Sq tp_
77 6509b181 2022-12-30 thomas prefix.
78 6509b181 2022-12-30 thomas .It
79 6509b181 2022-12-30 thomas Blanks are, in most cases, trimmed.
80 6509b181 2022-12-30 thomas Normally this is not a problem, but a workaround is needed in case
81 6509b181 2022-12-30 thomas they need to be preserved, for e.g.:
82 6509b181 2022-12-30 thomas .Bd -literal -offset indent
83 6509b181 2022-12-30 thomas Name: {{ " " }} {{ render name_field(tp) }}
84 6509b181 2022-12-30 thomas .Ed
85 6509b181 2022-12-30 thomas .El