Creating a formatCurrency function
This commit is contained in:
parent
20f7bd529f
commit
f952caf3f6
@ -22,7 +22,14 @@ type templateData struct {
|
|||||||
IsAuthenticated int
|
IsAuthenticated int
|
||||||
}
|
}
|
||||||
|
|
||||||
var functions = template.FuncMap{}
|
var functions = template.FuncMap{
|
||||||
|
"formatCurrency": formatCurrency,
|
||||||
|
}
|
||||||
|
|
||||||
|
func formatCurrency(n int) string {
|
||||||
|
f := float32(n / 100)
|
||||||
|
return fmt.Sprintf("€%.2f", f)
|
||||||
|
}
|
||||||
|
|
||||||
//go:embed templates
|
//go:embed templates
|
||||||
var templateFS embed.FS
|
var templateFS embed.FS
|
||||||
|
@ -19,8 +19,8 @@ Buy one widget
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
novalidate="">
|
novalidate="">
|
||||||
<input type="hidden" name="product_id" value="{{$widget.ID}}">
|
<input type="hidden" name="product_id" value="{{$widget.ID}}">
|
||||||
<input type="hidden" name="amount" value="{{$widget.Price}}">
|
<input type="hidden" id="amount" name="amount" value="{{$widget.Price}}">
|
||||||
<h3 class="mt-2 mb-3 text-center">{{$widget.Name}}: {{$widget.Price}}</h3>
|
<h3 class="mt-2 mb-3 text-center">{{$widget.Name}}: {{formatCurrency $widget.Price}}</h3>
|
||||||
<p class="mt-2 mb-3 text-center">{{$widget.Description}}</p>
|
<p class="mt-2 mb-3 text-center">{{$widget.Description}}</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user