templates

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package templates provides a set of standard functions that can be used in GitHub-related request templates.

Index

Constants

This section is empty.

Variables

View Source
var StandardFuncs = template.FuncMap{
	"cutHeadLines": func(n int, v string) string {
		tmp := strings.Split(v, "\n")
		if n == -1 || n > len(tmp) {
			return v
		}
		return strings.Join(tmp[n:], "\n")
	},
	"color": func(color, v string) string {
		tmp := strings.Split(v, "\n")
		for i, line := range tmp {

			tmp[i] = fmt.Sprintf(`${{\large\color{%s}{\texttt{ %s \}}}}\$`, color, line)
		}
		return strings.Join(tmp, "\n")
	},
	"toYaml": func(v any) string {
		b, _ := yaml.Marshal(v)
		return string(b)
	},
	"replace": func(old, new, s string) string {
		return strings.ReplaceAll(s, old, new)
	},
	"substr": func(s string, start, end int) string {
		if end == -1 {
			return s[start:]
		}
		return s[start:end]
	},
	"addLinesPrefix": func(prefix, value string) string {
		return prefix + strings.Join(strings.Split(value, "\n"), "\n"+prefix)
	},
}

StandardFuncs is a map of standard functions that can be used in GitHub-related request templates.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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