Documentation
¶
Overview ¶
Package meter provides constructors and methods for the HTML <meter> element.
The <meter> HTML element represents either a scalar value within a known range or a fractional value.
Index ¶
- Variables
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func Static(str string) *element
- func Text(str string) *element
- func Textf(format string, args ...any) *element
- func ValueMax(value float64, max float64, nodes ...node.Node) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<meter") TagClose = []byte("</meter>") AttrValue = []byte(" value=\"") AttrMin = []byte(" min=\"") AttrMax = []byte(" max=\"") AttrLow = []byte(" low=\"") AttrHigh = []byte(" high=\"") AttrOptimum = []byte(" optimum=\"") )
Byte constants for HTML rendering.
Functions ¶
func New ¶
New creates a new meter element with optional child nodes Example: meter.New() Renders: <meter></meter>
func RawText ¶
func RawText(str string) *element
RawText creates a new meter element with raw fallback text content. Uses text.RawText which is not HTML-escaped. Example: meter.RawText("<strong>6</strong> out of 10") Renders: <meter><strong>6</strong> out of 10</meter>
func RawTextf ¶
RawTextf creates a new meter element with formatted raw fallback text content. Uses text.RawTextf which is not HTML-escaped. Example: meter.RawTextf("<strong>%d</strong> out of %d", current, total) Renders: <meter><strong>7</strong> out of 10</meter>
func Static ¶
func Static(str string) *element
Static creates a new meter element with static fallback text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: meter.Static("75%") Renders: <meter>75%</meter>
func Text ¶
func Text(str string) *element
Text creates a new meter element with fallback text content. Uses text.Text which HTML-escapes the output. Example: meter.Text("6 out of 10") Renders: <meter>6 out of 10</meter>