Lindenii Project Forge
Login

hare-htmpl

HTML templating engine for Hare
Commit info
ID
e01ea2ab73482dbfc40d2480e2f05a0c9ec4120c
Author
Runxi Yu <me@runxiyu.org>
Author date
Thu, 13 Mar 2025 19:32:21 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Thu, 13 Mar 2025 19:32:21 +0800
Actions
Update documentation for htmplgen.1
.\" Copyright (c) 2022 Omar Polo <op@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd January 6, 2022
.Dt TEMPLATE 1
.Os
.Sh NAME
.Nm htmplgen
.Nd templating system compiler
.Sh SYNOPSIS
.Nm
.Op Fl G
.Op Fl o Ar out
.Op Ar
.Sh DESCRIPTION
.Nm
is an utility that converts files written in the
.Xr htmpl 7
format format to a set of routine writtens in the C programming
language.
.Nm
converts the files given as arguments or from standard input, and
writes to standard output.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl G
Do not emit debug info in the generated source.
It's disabled by default, unless
.Nm
is reading from standard input.
.It Fl o Ar out
Write output to file.
.Ar out
will be created or truncated if exists and will be removed if
.Nm
encounters any error.
.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr htmpl 7
.Sh AUTHORS
.An -nosplit
The
.Nm
utility was written by
.An Omar Polo Aq Mt op@openbsd.org .
.An Omar Polo Aq Mt op@openbsd.org
wrote the original version in C.
.An Runxi Yu Aq Mt me@runxiyu.org
ported it to Hare.
.Sh CAVEATS
The compiler is very naive, so there are quite a few shortcomings:
.Bl -bullet -compact
.It
No attempt is made to validate the C code provided inline, nor the
No attempt is made to validate the Hare code provided inline, nor the
validity of the arguments to many constructs.
.It
The generated code assumes that a variable called
.Va tp
.Va handle
of type
.Vt struct template *
.Vt io::handle
is in scope inside each block.
.It
Each block may have additional variables used for the template
generation implicitly defined: to avoid clashes, don't name variables
or arguments with the
.Sq tp_
.Sq _htmpl_
prefix.
.It
Blanks are, in most cases, trimmed.
Normally this is not a problem, but a workaround is needed in case
they need to be preserved, for e.g.:
.Bd -literal -offset indent
Name: {{ " " }} {{ render name_field(tp) }}
.Ed
.El