util

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Utilities for templating strings more easily

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(text string) string

Capitalize the first letter of a string Uses unicode title case rules. If the first character is not capitalizable, the string is returned unchanged.

func CheckProperty

func CheckProperty(data any, path string, value any) (bool, error)

Dynamically resolve a dot-separated property path and check if the result matches a value

func ExecuteTemplate

func ExecuteTemplate(templateStr string, context any) (string, error)

Helper function to execute a template once

Types

type TypedTemplate

type TypedTemplate[T any] struct {
	template.Template
}

Define a template with a type-checked data type T

func NewTypedTemplate

func NewTypedTemplate[T any](templateStr string) (*TypedTemplate[T], error)

func (*TypedTemplate[T]) Execute

func (tpl *TypedTemplate[T]) Execute(wr io.Writer, data T) error

func (*TypedTemplate[T]) ExecuteStr

func (tpl *TypedTemplate[T]) ExecuteStr(data T) (string, error)

Jump to

Keyboard shortcuts

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