Reference
Field types
The four field types of Brevier and what each does to whitespace and markup, and how a schema declares them.
On this page
A field type says what may be in a value. It also says what happens to
whitespace and markup before the value reaches the page. text is the
default.
| Field type | Input | Output | Does |
|---|---|---|---|
text |
"Anna <b>Berg</b>\n" |
Anna <b>Berg</b> |
Runs of spaces and line breaks become one space. The ends are trimmed. Markup is escaped. |
multiline |
"Line 1\nLine <b>2</b>" |
Line 1<br>Line <b>2</b> |
A line break becomes <br>. Other markup is escaped. For addresses and notes. |
rich |
"<b>bold</b> <script>x()</script><a href=\"javascript:x()\">link</a>" |
<b>bold</b> <a>link</a> |
Bold, italic, lists, links and line breaks stay. Other markup is removed. For text from a CMS. |
raw |
"<b>x</b>" |
<b>x</b> |
The value passes unchanged. Use it only for markup that you trust. |
A name that is not one of the four types is treated as text.
What rich keeps
- Tags:
b,i,em,strong,ul,ol,li,a,br,pandspan. - Attributes:
hrefandtitleona, andclassonpandspan. - Links: an
hrefwith the schemehttp,https,mailtoortel, or with no scheme, stays. A link with another scheme, such asjavascript:, loses itshref. - Event attributes such as
onclickare removed. - Any other tag is removed and its text stays.
scriptandstylelose their text too.
Declare a field type
Give the field x-brevier-type in the template's schema: the file
rechnung.schema.json next to rechnung.html, or the schema that
--schema names.
rechnung.schema.json
{
"type": "object",
"properties": {
"bemerkung": { "type": "string", "x-brevier-type": "multiline" }
}
}brevier pdf,brevier html,brevier lint,brevier preview,brevier serveand the clients bind the field with that type.- A field without
x-brevier-typeistext. So is every field of a template that has no schema. - The type belongs to the field's place in the schema, not to its name.
kunde.namecan berichwhilelieferant.namestaystext. - The front-matter
fields:block, thepage:header and footer, and the PythonPdfbuilder do not use field types yet: their fields aretext.