Templates
Templates make document creation faster and more consistent. In FiveNet, templates use HTML plus Golang templating to insert dynamic data.
- Base Golang
html/templatefunctions - Additional
sprigtemplate functions
How Rendering Works
When a template is used, FiveNet:
- Takes your HTML content.
- Replaces template expressions like
{{ .ActiveChar.Firstname }}with real values. - Renders the final result as HTML in the document editor.
Clipboard selections provide data for:
.Users.Vehicles.Documents
Minimum Working Template
Use this as a safe starting point:
<p>
Created by: {{ .ActiveChar.Firstname }} {{ .ActiveChar.Lastname }}<br>
Date: {{ now | date "02.01.2006" }}
</p>
Core Building Blocks
Variables
{{ .ActiveChar.Firstname }}
Conditionals
{{ if .Users }}
<p>Users selected.</p>
{{ else }}
<p>No users selected.</p>
{{ end }}
Loops
<ul>
{{- range .Vehicles -}}
<li>{{ .Plate }} - {{ .Owner.Firstname }} {{ .Owner.Lastname }}</li>
{{- end -}}
</ul>
Common Helpers
{{- $citizen := first .Users -}}
{{ now | date "02.01.2006 15:04" }}
Copy-Ready Snippets
First Selected Citizen
{{- if .Users -}}
{{- $citizen := first .Users -}}
<p>
Citizen: {{ $citizen.Firstname }} {{ $citizen.Lastname }}<br>
DOB: {{ $citizen.Dateofbirth }}
</p>
{{- else -}}
<p>No citizen selected.</p>
{{- end -}}
Vehicle List With Fallback
{{ if not .Vehicles }}
<p>No vehicles involved.</p>
{{ else }}
<ul>
{{- range .Vehicles -}}
<li>{{ .Plate }} - {{ .Owner.Firstname }} {{ .Owner.Lastname }}</li>
{{- end -}}
</ul>
{{ end }}
Signature Block
<p>
Submitted by: {{ .ActiveChar.Firstname }} {{ .ActiveChar.Lastname }}<br>
Rank: {{ .ActiveChar.JobGradeLabel }}<br>
Date: {{ now | date "02.01.2006 15:04" }}
</p>
Common Mistakes
- Invalid HTML output (missing/incorrect tags).
- Using
.activeCharinstead of.ActiveChar. - Accessing list items without checking if the list has data.
- Forgetting
<br>for line breaks in paragraphs.
Available Variables
.Documents
List of documents 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 in the user's clipboard.
- See User Info Structure.
.Vehicles
List of vehicles in the user's clipboard.
.Plate.Model.Type.Owner- See User Info Structure.
.ActiveChar
Author/submitting user information.
- See User Info Structure.
User Info Structure
.UserId.Identifier.Job- Preferably use.JobLabel..JobLabel*.JobGrade- Preferably use.JobGradeLabel..JobGradeLabel*.Firstname.Lastname.Dateofbirth- InDD.MM.YYYYformat..PhoneNumber- Optional, might not always be included.
(*These fields are only available on the .ActiveChar variable.)
Additional Snippets
Access Active User Info
{{ .ActiveChar.Firstname }}, {{ .ActiveChar.Lastname }}
Get First Citizen
Get the first user in the list (first item in the user's clipboard):
{{- $citizen := first .Users -}}
Example to 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.
Current Date
{{ now | date "02.01.2006" }}
To learn more about different date and time formats, check out the Golang time package documentation here.
Showing a Timestamp (e.g., CreatedAt field)
{{ .CreatedAt | date "02.01.2006 15:04" }}
Checkboxes
Inline-Checkbox
<span data-checked="false" data-type="checkboxStandalone"><label><input type="checkbox"> </label></span>
Example usage:
<p>Checkbox inline <span data-checked="false" data-type="checkboxStandalone"><label><input type="checkbox"> </label></span>with text</p>
Task List (Checkboxes List)
<ul data-type="taskList">
<li data-checked="false" data-type="taskItem">
<label><input type="checkbox"><span></span></label><div><p>Your first text goes here</p></div>
<label><input type="checkbox"><span></span></label><div><p>Your second text goes here</p></div>
</li>
</ul>
Checkbox List Item
<label><input type="checkbox"><span></span></label><div><p>Your text goes here</p></div>
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 }}
