50 lines
1 KiB
HTML
50 lines
1 KiB
HTML
<!--
|
|
Renders a role's class (i.e. colour based on paid/unpaid).
|
|
|
|
@params end_date The end date of the role, or undefined if the role is ongoing.
|
|
@params is_paid Whether the role is paid or not.
|
|
-->
|
|
|
|
<!-- Validation -->
|
|
|
|
{{- if ( not ( isset . "end_date" ) ) -}}
|
|
{{- errorf "No end date passed" -}}
|
|
{{- end -}}
|
|
|
|
{{- if ( not ( isset . "is_paid" ) ) -}}
|
|
{{- errorf "No 'is_paid' passed" -}}
|
|
{{- end -}}
|
|
|
|
|
|
<!-- Variable Assignment -->
|
|
|
|
{{- $end_date := .end_date -}}
|
|
{{- $is_paid := .is_paid -}}
|
|
|
|
|
|
<!-- Variable Initialisation -->
|
|
|
|
{{- $unpaid_past := "#FFFFF0" -}}
|
|
{{- $paid_past := "#FCFCA6" -}}
|
|
{{- $unpaid_current := "#BBBBB0" -}}
|
|
{{- $paid_current := "#BCBC7E" -}}
|
|
{{- $colour := "" -}}
|
|
|
|
|
|
<!-- Rendering -->
|
|
|
|
{{- if $end_date -}}
|
|
{{- if $is_paid -}}
|
|
{{- $colour = $paid_past -}}
|
|
{{- else -}}
|
|
{{- $colour = $unpaid_past -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- if $is_paid -}}
|
|
{{- $colour = $paid_current -}}
|
|
{{- else -}}
|
|
{{- $colour = $unpaid_current -}}
|
|
{{- end -}}
|
|
{{- end }}
|
|
|
|
{{- return $colour -}}
|