Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 874 Bytes

File metadata and controls

38 lines (27 loc) · 874 Bytes

format

Formatting utilities for prices and numbers. Pure functions without HTML output.

Usage

import "hatmax.adrianpk.com/format"

// Numbers
format.Number(1234567)    // "1,234,567"
format.Integer(1234.56)   // "1,235"

// Prices
format.Price(150000, "USD")          // "$150,000"
format.Price(150000, "EUR")          // "150,000 €"
format.PriceWithDecimals(99.99, "USD") // "$99.99"
format.PriceRange(100, 500, "USD")   // "$100 - $500"

// Register custom currencies
format.RegisterCurrency("CLP", "$", format.SymbolBefore)

Template Usage

Available via ui.FuncMap():

<span class="price">{{ formatPrice .Amount .Currency }}</span>
<span class="count">{{ formatNumber .Count }}</span>