helpers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package helpers contains helper functions for templates. All functions in this package are exposed to templates with the same name, but in all lowercase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dict

func Dict(values ...any) (map[string]any, error)

Dict creates a dictionary (map[string]any) from pairs of arguments. An uneven number of arguments will cause an error to be returned. The keys (i.e. uneven arguments) must be strings.

Example:

{{ dict "foo" "bar" "baz" 42 | ... }}

would create:

map[string]any {
  "foo": "bar",
  "baz": 42,
}

func Env

func Env(name string) (string, error)

Env returns the value of environment variable referenced by name. If the name is not found in the environment, an error is returned.

func Gql

func Gql(input string) (template.HTML, error)

Gql syntax-highlights the GraphQL code input as HTML.

func Html

func Html(input string) template.HTML

Html marks the input as "safe", so templates will not escape it.

func ID

func ID(element any) (string, error)

ID generates a unique ID based on the type and name of element. The returned ID is suitable for use as HTML id attribute.

Only the following types are supported as arugment:

func Md

func Md(input string) (string, error)

Md renders the markdown-formatted input as HTML.

Types

This section is empty.

Jump to

Keyboard shortcuts

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