Front
{{range .Device.Ports}}{{if eq .Side "front"}}
{{$pid := .ID}}
{{$color := "#333"}}{{$bg := ""}}
{{range $.Connections}}{{if and .Port1 .Port2}}{{if eq .Port1.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{else if eq .Port2.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{end}}{{end}}{{end}}
{{.Name}}
{{end}}{{end}}
Back
{{range .Device.Ports}}{{if eq .Side "back"}}
{{$pid := .ID}}
{{$color := "#333"}}{{$bg := ""}}
{{range $.Connections}}{{if and .Port1 .Port2}}{{if eq .Port1.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{else if eq .Port2.ID $pid}}{{$color = .Color}}{{$bg = .Color}}{{end}}{{end}}{{end}}
{{.Name}}
{{end}}{{end}}
{{end}}