funcs

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a any, b ...any) (r any, err error)

Add returns the result of a + b[0] + b[1] ...

func Array

func Array(args ...any) []any

Array returns a []any{args[0], args[1], ...}

func CSS

func CSS(a any) (template.CSS, error)

func Comma

func Comma(n any, c ...string) (string, error)

Comma produces a string form of the given number in base 10 with commas after every three orders of magnitude.

e.g. Comma(834142) -> 834,142 e.g. Comma(834142, "_") -> 834_142

func Divide

func Divide(a any, b ...any) (r any, err error)

Divide returns the result of a / b[0] / b[1] ...

func HTML

func HTML(a any) (template.HTML, error)

func HTMLAttr

func HTMLAttr(a any) (template.HTMLAttr, error)

func HumanSize

func HumanSize(n any) (string, error)

HumanSize returns a human-readable approximation of a size capped at 4 valid numbers (eg. "2.746 MB", "796 KB").

func JS

func JS(a any) (template.JS, error)

func JSON

func JSON(a any) (template.JS, error)

JSON returns a json marshal string.

func JSStr

func JSStr(a any) (template.JSStr, error)

func Map

func Map(kvs ...any) (map[string]any, error)

Map returns a map[string]any{kvs[0]: kvs[1], kvs[2]: kvs[3], ...}

func MapGet

func MapGet(dict any, keys ...any) (any, error)

MapGet getting value from map by keys usage:

Data["m"] = map[string]any{
    "a": 1,
    "1": map[string]float64{
        "c": 4,
    },
}

{{MapGet m "a" }} // return 1 {{MapGet m 1 "c" }} // return 4

func MapSet

func MapSet(dict any, key, val any) (any, error)

MapSet setting value to the map

func Multiply

func Multiply(a any, b ...any) (r any, err error)

Multiply returns the result of a * b[0] * b[1] ...

func Srcset

func Srcset(a any) (template.Srcset, error)

func Subtract

func Subtract(a any, b ...any) (r any, err error)

Subtract returns the result of a - b[0] - b[1] ...

func URL

func URL(a any) (template.URL, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL