...why didn't my docs regen hook run?
This commit is contained in:
brent saner
2026-01-28 09:20:34 -05:00
parent 9cce861b2e
commit 64a7648fbc
2 changed files with 285 additions and 169 deletions

View File

@@ -7,8 +7,21 @@ docs](https://pkg.go.dev/github.com/Masterminds/sprig/v3)).
They provide functions that offer more enriched use cases and
domain-specific data.
If you are reading this README on the Go Module Directory documentation
(<https://pkg.go.dev/r00t2.io/goutils/tplx/sprigx>) or the directory
landing page
(<https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx>),
it may not render correctly.
Be sure to view it at properly via [the AsciiDoc
rendering](https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx/README.adoc)
or by downloading and viewing the [HTML
version](https://git.r00t2.io/r00t2/go_goutils/raw/branch/master/tplx/sprigx/README.html).
# How do I Use SprigX?
The same way you would `sprig`!
package main
import (
@@ -20,17 +33,19 @@ domain-specific data.
var (
txtTpl *txtTplLib.Template = txtTplLib.
New("").
Funcs(
sprigx.TxtFuncMap(),
)
New("").
Funcs(
sprigx.TxtFuncMap(),
)
htmlTpl *htmlTplLib.Template = htmlTplLib.
New("").
Funcs(
sprigx.HtmlFuncMap(),
)
New("").
Funcs(
sprigx.HtmlFuncMap(),
)
)
They can even be combined/used together.
package main
import (
@@ -41,23 +56,23 @@ domain-specific data.
)
var txtTpl *template.Template = template.
New("").
Funcs(
sprigx.TxtFuncMap(),
).
Funcs(
sprig.TxtFuncMap(),
)
New("").
Funcs(
sprigx.TxtFuncMap(),
).
Funcs(
sprig.TxtFuncMap(),
)
// Or:
/*
var txtTpl *template.Template = template.
New("").
Funcs(
sprig.TxtFuncMap(),
).
Funcs(
sprigx.TxtFuncMap(),
)
New("").
Funcs(
sprig.TxtFuncMap(),
).
Funcs(
sprigx.TxtFuncMap(),
)
*/
If a `<template>.FuncMap` is added via `.Funcs()` **after** template
@@ -66,30 +81,7 @@ parsing, it will override any functions of the same name of a
For example, if both `sprig` and `sprigx` provide a function `foo`:
package main
import (
"text/template"
"github.com/Masterminds/sprig/v3"
"r00t2.io/goutils/tplx/sprigx"
)
const (
myTpl string = `{{ "This is an example template string." | foo }}`
)
var (
tpl *template.Template = template.Must(
template.
New("").
Funcs(sprig.TxtFuncMap()).
Parse(myTpl),
).
Funcs(sprigx.TxtFuncMap())
)
whereas
this will use `foo` from `sprigx`
package main
@@ -106,15 +98,40 @@ whereas
var (
tpl *template.Template = template.Must(
template.
New("").
Funcs(sprigx.TxtFuncMap()).
Parse(myTpl),
).
Funcs(sprig.TxtFuncMap())
template.
New("").
Funcs(sprig.TxtFuncMap()).
Parse(myTpl),
).
Funcs(sprigx.TxtFuncMap())
)
and a function can even be
whereas this will use `foo` from `sprig`
package main
import (
"text/template"
"github.com/Masterminds/sprig/v3"
"r00t2.io/goutils/tplx/sprigx"
)
const (
myTpl string = `{{ "This is an example template string." | foo }}`
)
var (
tpl *template.Template = template.Must(
template.
New("").
Funcs(sprigx.TxtFuncMap()).
Parse(myTpl),
).
Funcs(sprig.TxtFuncMap())
)
and a function can even be explicitly overridden.
This would override a function `foo` and `foo2` in `sprigx` from `foo`
and `foo2` from `sprig`, but leave all other `sprig` functions
@@ -136,19 +153,19 @@ untouched.
var (
overrideFuncs template.FuncMap = sprig.TxtFuncMap()
tpl *template.Template = template.Must(
template.
New("").
Funcs(sprigx.TxtFuncMap()).
Parse(myTpl),
).
Funcs(
template.FuncMap(
map[string]any{
"foo": overrideFuncs["foo"],
"foo2": overrideFuncs["foo2"],
},
),
)
template.
New("").
Funcs(sprigx.TxtFuncMap()).
Parse(myTpl),
).
Funcs(
template.FuncMap(
map[string]any{
"foo": overrideFuncs["foo"],
"foo2": overrideFuncs["foo2"],
},
),
)
)
# Functions
@@ -156,7 +173,18 @@ untouched.
Expect this list to grow over time, and potentially more frequently than
the `sprigx` functions.
## System/OS/Platform
## Operating System
### `osHostname`
`osHostname` simply wraps and returns the result of calling
[`os.Hostname`](https://pkg.go.dev/os#Hostname).
As such, it comes with the same caveats - its possible for it to error,
and it isnt guaranteed to be an FQDNit will be precisely/exactly
whatever the kernels hostname is set as.
## System/Platform/Architecture
### `sysArch`
@@ -277,7 +305,8 @@ library](https://pkg.go.dev/path) and use a fixed `/` path separator.
[`path.Join`](https://pkg.go.dev/path#Join) in stdlib.
If you are joining paths in a pipeline, you almost assuredly want
[](#fn_path_gnrc_ppj) or [](#fn_path_gnrc_pspj) instead.
[](#fn_path_gnrc_ppj) or [](#fn_path_gnrc_pspj) instead unless you are
explicitly **appending** a pipeline result to a path.
{{- pathJoin "a" "b" "c" }}
{{- pathJoin "/" "a" "b" "c" }}
@@ -384,7 +413,8 @@ path bases/roots if needed.
[`path/filepath.Join`](https://pkg.go.dev/path/filepath#Join) in stdlib.
If you are joining paths in a pipeline, you almost assuredly want
[](#fn_path_os_ppj) or [](#fn_path_os_pspj) instead.
[](#fn_path_os_ppj) or [](#fn_path_os_pspj) instead unless you are
explicitly **appending** a pipeline result to a path.
{{- osPathJoin "a" "b" "c" }}
{{- osPathJoin "/" "a" "b" "c" }}
@@ -629,6 +659,9 @@ renders as:
It works with both Windows (`\r\n`) and POSIX (`\n`) linebreaks.
If `<indentString>` is set to `\n` and `<levels>` is always set to `1`,
this function can even be used to doubelspace text!
It has quite a few arguments, however:
{{ extIndent <levels> <skipFirst> <skipEmpty> <skipWhitespace> <indentString> <input> }}
@@ -654,3 +687,13 @@ Where:
- `<input>`: The text to be indented. Because it is the last argument,
`extIndent` works with pipelined text as well.
## Debugging
### `dump`
The `dump` function calls [the `Sdump`
function](https://pkg.go.dev/github.com/davecgh/go-spew/spew#Sdump) from
[`go-spew`](https://github.com/davecgh/go-spew)
([`github.com/davecgh/go-spew/spew`](https://pkg.go.dev/github.com/davecgh/go-spew/spew))
for whatever object(s) is/are passed to it.