templates

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnsiParse

func AnsiParse(input string) string

func ClearTemplateConfigCache

func ClearTemplateConfigCache(userId int)

func DynamicList

func DynamicList(itmNames []NameDescription, colWidth, sw, numWidth, longestName int) string

DynamicList takes a slice of NameDescription items and formats them into a string NOTE: This is a first step to moving dynamic lists into a common function.

func Exists

func Exists(name string) bool

func LoadAliases

func LoadAliases(f ...fileloader.ReadableGroupFS)

Loads the ansi aliases from the config file Only if the file has been modified since the last load

func Process

func Process(fname string, data any, receivingUserId ...int) (string, error)

func ProcessText

func ProcessText(text string, data any, ansiFlags ...AnsiFlag) (string, error)

func RegisterFS

func RegisterFS(f fs.ReadFileFS)

func SetAnsiFlag

func SetAnsiFlag(flag AnsiFlag)

Configure a forced ansi flag setting

func TNL

func TNL(userId int) string

func TplAnsiParse

func TplAnsiParse(input string) string

Types

type AnsiFlag

type AnsiFlag uint8
const (
	AnsiTagsDefault AnsiFlag          = iota // Do not parse tags
	AnsiTagsParse                            // Parse ansi tags before returning contents of template
	AnsiTagsStrip                            // strip out all ansi tags and leave text plain
	AnsiTagsMono                             // Parse ansi tags, but strip out all color information
	AnsiTagsNone    = AnsiTagsDefault        // alias to default

	ForceScreenReaderUserId = -1
)

type NameDescription

type NameDescription struct {
	Id          any  // optional identifier.
	Marked      bool // mark in some way?
	Name        string
	Description string
}

A common structure used in templating

type TemplateTable

type TemplateTable struct {
	Title              string
	Header             []string
	Rows               [][]string
	TrueHeaderCellSize []int
	TrueCellSize       [][]int
	ColumnCount        int
	ColumnWidths       []int
	Formatting         [][]string
	// contains filtered or unexported fields
}

func GetTable

func GetTable(title string, headers []string, rows [][]string, formatting ...[]string) TemplateTable

func (TemplateTable) GetCell

func (t TemplateTable) GetCell(row int, column int) string

func (TemplateTable) GetHeaderCell

func (t TemplateTable) GetHeaderCell(column int) string

Jump to

Keyboard shortcuts

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