|
1 | | -{{- $emailTemplates := .Params.email_templates -}} |
2 | | -{{- $fip50Email := and $emailTemplates (index $emailTemplates "fip_50") -}} |
3 | | -{{- $globalFareEmail := and $emailTemplates (index $emailTemplates "fip_global_fare") -}} |
4 | | -{{- $reservationEmail := and $emailTemplates (index $emailTemplates "reservations") -}} |
5 | | -{{- $showGlobalFareEmailButton := and (eq .Params.type "email") (eq .Params.fip_global_fare true) $globalFareEmail $globalFareEmail.to $globalFareEmail.subject $globalFareEmail.body -}} |
6 | | -{{- $showFip50EmailButton := and (eq .Params.type "email") (eq .Params.fip_50 true) $fip50Email $fip50Email.to $fip50Email.subject $fip50Email.body -}} |
7 | | -{{- $showReservationEmailButton := and (eq .Params.type "email") (eq .Params.reservations true) $reservationEmail $reservationEmail.to $reservationEmail.subject $reservationEmail.body -}} |
8 | | -{{- if or .Params.booking_link .Params.additional_info_link $showGlobalFareEmailButton $showFip50EmailButton $showReservationEmailButton -}} |
| 1 | +{{- $params := .params -}} |
| 2 | +{{- $emailTemplates := $params.email_templates -}} |
| 3 | +{{- $emailTypes := slice "fip_50" "fip_75" "fip_global_fare" "reservations" -}} |
| 4 | +{{- $emailButtons := slice -}} |
| 5 | +{{- range $emailType := $emailTypes -}} |
| 6 | + {{- $metaMatches := where $.metaFields "key" $emailType -}} |
| 7 | + {{- $metaValue := false -}} |
| 8 | + {{- $metaLabel := "" -}} |
| 9 | + {{- if gt (len $metaMatches) 0 -}} |
| 10 | + {{- $metaValue = (index $metaMatches 0).value -}} |
| 11 | + {{- $metaLabel = (index $metaMatches 0).label -}} |
| 12 | + {{- end -}} |
| 13 | + {{- $template := and $emailTemplates (index $emailTemplates $emailType) -}} |
| 14 | + {{- $showEmailButton := and (eq $params.type "email") (eq $metaValue true) $template $template.to $template.subject $template.body -}} |
| 15 | + {{- if $showEmailButton -}} |
| 16 | + {{- $buttonText := T "booking.send-mail" -}} |
| 17 | + {{- if $metaLabel -}} |
| 18 | + {{- $buttonText = printf "%s (%s)" (T "booking.send-mail") (T $metaLabel) -}} |
| 19 | + {{- end -}} |
| 20 | + {{- $emailButtons = $emailButtons | append (dict |
| 21 | + "Destination" (printf "mailto:%s?subject=%s&body=%s" $template.to (replace ($template.subject | urlquery) "+" "%20") (replace ($template.body | urlquery) "+" "%20")) |
| 22 | + "Text" $buttonText |
| 23 | + ) |
| 24 | + -}} |
| 25 | + {{- end -}} |
| 26 | +{{- end -}} |
| 27 | +{{- if or $params.booking_link $params.additional_info_link (gt (len $emailButtons) 0) -}} |
9 | 28 | <div class="o-booking__links"> |
10 | | - {{- if .Params.booking_link -}} |
| 29 | + {{- if $params.booking_link -}} |
11 | 30 | {{- partial "button" |
12 | 31 | (dict |
13 | | - "Destination" .Params.booking_link |
| 32 | + "Destination" $params.booking_link |
14 | 33 | "Text" (T "booking.visit-booking-website") |
15 | 34 | ) |
16 | 35 | -}} |
17 | 36 | {{- end -}} |
18 | | - {{- if .Params.additional_info_link -}} |
| 37 | + {{- if $params.additional_info_link -}} |
19 | 38 | {{- partial "button" |
20 | 39 | (dict |
21 | | - "Destination" .Params.additional_info_link |
| 40 | + "Destination" $params.additional_info_link |
22 | 41 | "Text" (T "booking.visit-additional-information-website") |
23 | 42 | ) |
24 | 43 | -}} |
25 | 44 | {{- end -}} |
26 | | - {{- if $showGlobalFareEmailButton -}} |
27 | | - {{- partial "button" |
28 | | - (dict |
29 | | - "Destination" (printf "mailto:%s?subject=%s&body=%s" $globalFareEmail.to (replace ($globalFareEmail.subject | urlquery) "+" "%20") (replace ($globalFareEmail.body | urlquery) "+" "%20")) |
30 | | - "Text" (T "booking.send-mail-fip-global-fare") |
31 | | - ) |
32 | | - -}} |
33 | | - {{- end -}} |
34 | | - {{- if $showFip50EmailButton -}} |
35 | | - {{- partial "button" |
36 | | - (dict |
37 | | - "Destination" (printf "mailto:%s?subject=%s&body=%s" $fip50Email.to (replace ($fip50Email.subject | urlquery) "+" "%20") (replace ($fip50Email.body | urlquery) "+" "%20")) |
38 | | - "Text" (T "booking.send-mail-fip-50-ticket") |
39 | | - ) |
40 | | - -}} |
41 | | - {{- end -}} |
42 | | - {{- if $showReservationEmailButton -}} |
43 | | - {{- partial "button" |
44 | | - (dict |
45 | | - "Destination" (printf "mailto:%s?subject=%s&body=%s" $reservationEmail.to (replace ($reservationEmail.subject | urlquery) "+" "%20") (replace ($reservationEmail.body | urlquery) "+" "%20")) |
46 | | - "Text" (T "booking.send-mail-reservation") |
47 | | - ) |
48 | | - -}} |
| 45 | + {{- range $emailButtons -}} |
| 46 | + {{- partial "button" . -}} |
49 | 47 | {{- end -}} |
50 | 48 | </div> |
51 | 49 | {{- end -}} |
0 commit comments