Creating a formatCurrency function
This commit is contained in:
parent
20f7bd529f
commit
f952caf3f6
@ -22,7 +22,14 @@ type templateData struct {
|
||||
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
|
||||
var templateFS embed.FS
|
||||
|
@ -19,8 +19,8 @@ Buy one widget
|
||||
autocomplete="off"
|
||||
novalidate="">
|
||||
<input type="hidden" name="product_id" value="{{$widget.ID}}">
|
||||
<input type="hidden" name="amount" value="{{$widget.Price}}">
|
||||
<h3 class="mt-2 mb-3 text-center">{{$widget.Name}}: {{$widget.Price}}</h3>
|
||||
<input type="hidden" id="amount" name="amount" value="{{$widget.Price}}">
|
||||
<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>
|
||||
<hr>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user