rastrillo / abono Public

Clone
git clone https://amadan.net/rastrillo/abono

Plain git — no account needed to clone.

Download

Download this file

1{{/* abono-plan-picker — the plans on sale, as cards grouped by interval:
2 the monthly plans, then the yearly ones. A plan appears in a group
3 only when it has a price sold at that interval (every month or every
4 year: an unsupported price is never shown). With only one
5 interval on sale there is one group and no switch label; with nothing
6 on sale the picker renders nothing.
7
8 The groups are all on the page, not toggled by script, so the picker
9 works without JavaScript and every price is readable at once.
10
11 Keys:
12 Offers []abono.Offer, required — from Service.Offers
13 Action string, required — where each card's buy form posts
14 L *ui.Localizer */}}
15{{define "abono-plan-picker"}}{{$L := localizer $}}{{$action := .Action}}{{$month := false}}{{$year := false}}{{range .Offers}}{{range .Prices}}{{if and .Sold (not .Unsupported)}}{{if eq .Interval "month"}}{{$month = true}}{{else if eq .Interval "year"}}{{$year = true}}{{end}}{{end}}{{end}}{{end}}{{if or $month $year}}<div{{if and $month $year}} role="group" aria-label="{{T $L "abono.price.switch_label"}}"{{end}}>{{range $iv := list "month" "year"}}{{if or (and (eq $iv "month") $month) (and (eq $iv "year") $year)}}<section>{{if and $month $year}}<p><strong>{{if eq $iv "month"}}{{T $L "abono.price.monthly"}}{{else}}{{T $L "abono.price.yearly"}}{{end}}</strong></p>{{end}}{{range $.Offers}}{{$has := false}}{{range .Prices}}{{if and .Sold (not .Unsupported) (eq .Interval $iv)}}{{$has = true}}{{end}}{{end}}{{if $has}}{{template "abono-plan-card" dict "L" $L "Offer" . "Interval" $iv "Action" $action}}{{end}}{{end}}</section>{{end}}{{end}}</div>{{end}}{{end}}
16