Documents
Templates
Templates can be used to make creating documents easier.
Templates can be used to make creating documents easier.
Golang HTML templating is used.
In addition to the base Golang html/template functions, the
sprig
template functions are available for convience.Points to watch out when creating a template:
- The whole template needs to be wrapped in
<p>
and</p>
. - Use
<br>
for new lines.
A template must render out to valid HTML.
Available Variables
.Documents
- List of documents that are in the user's clipboard..Id
.CreatedAt
.Title
.State
.CreatorId
.Creator
- See User Info Structure..Closed
- Boolean..CategoryId
.Category
-.Name
.Description
.Users
- List of citizens/ users that are in the user's clipboard.- See User Info Structure.
.Vehicles
- List of vehicles that are in the user's clipboard.Plate
Model
Type
Owner
- See User Info Structure.
.ActiveChar
- Author/Submitting user's info.- See User Info Structure.
User Info Structure
.UserId
.Identifier
.Job
- - Preferrably usejobLabel
..JobLabel
*.JobGrade
- - Preferrably usejobGradeLabel
..JobGradeLabel
*.Firstname
.Lastname
.Dateofbirth
- InDD.MM.YYYY
format..PhoneNumber
- Optional, might not always be included.
(*these fields are only available on the .activeChar
variable)
Snippets
Access Creator Info
{{ .ActiveChar.Firstname }}, {{ .ActiveChar.Lastname }}
Get first Citizen
Get the first user in the list (first in the user's clipboard):
{{- $citizen := first .Users -}}
Example access citizen info:
{{ $citizen.Firstname }}, {{ $citizen.Lastname }} ({{ $citizen.Dateofbirth }})
Current Date and Time
{{ now | date "02.01.2006 15:04" }}
To learn more about different date and time formats, check out the Golang time
package documentation here.
Showing a Timestamp (e.g., CreatedAt
)
{{ .CreatedAt | date "02.01.2006 15:04" }}
Checkbox
<label contenteditable="false"><input type="checkbox"><span> Yes </span></label>
Examples
Displaying a list of Vehicles
{{ if not .Vehicles }}
<p>
No Vehicles involved.
</p>
{{ else }}
<ul>
{{- range .Vehicles -}}
<li>{{ .Plate }} - {{ .Owner.Firstname }}, {{ .Owner.Lastname }}</li>
{{- end -}}
</ul>
{{ end }}