diff --git a/tplx/sprigx/README.html b/tplx/sprigx/README.html index 5b1f9a4..551a4a6 100644 --- a/tplx/sprigx/README.html +++ b/tplx/sprigx/README.html @@ -559,7 +559,7 @@ pre.rouge .gs {
Brent Saner
bts@square-r00t.net
-Last rendered 2026-01-24 06:56:03 -0500 +Last rendered 2026-01-28 09:20:19 -0500
Table of Contents
@@ -568,40 +568,50 @@ pre.rouge .gs {
  • 2. How do I Use SprigX?
  • 3. Functions @@ -619,13 +629,35 @@ pre.rouge .gs {

    They provide functions that offer more enriched use cases and domain-specific data.

    +
    + + + + + +
    +
    Tip
    +
    +
    +

    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 +or by downloading and viewing the HTML version.

    +
    +
    +
  • 2. How do I Use SprigX?

    +
    +

    The same way you would sprig!

    +
    -The same way you would sprig! +Like this.
    @@ -640,22 +672,25 @@ pre.rouge .gs { 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.

    +
    -They can even be combined. +Like this.
    @@ -669,23 +704,23 @@ pre.rouge .gs { ) 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(), + ) */
    @@ -697,8 +732,11 @@ var txtTpl *template.Template = template.

    For example, if both sprig and sprigx provide a function foo:

    +
    +

    this will use foo from sprigx

    +
    -this will use foo from sprigx +(show)
    @@ -717,22 +755,22 @@ var txtTpl *template.Template = template. var ( tpl *template.Template = template.Must( - template. - New(""). - Funcs(sprig.TxtFuncMap()). - Parse(myTpl), - ). - Funcs(sprigx.TxtFuncMap()) + template. + New(""). + Funcs(sprig.TxtFuncMap()). + Parse(myTpl), + ). + Funcs(sprigx.TxtFuncMap()) )
    -

    whereas

    +

    whereas this will use foo from sprig

    -this will use foo from sprig +(show)
    @@ -751,22 +789,22 @@ var txtTpl *template.Template = template. var ( tpl *template.Template = template.Must( - template. - New(""). - Funcs(sprigx.TxtFuncMap()). - Parse(myTpl), - ). - Funcs(sprig.TxtFuncMap()) + template. + New(""). + Funcs(sprigx.TxtFuncMap()). + Parse(myTpl), + ). + Funcs(sprig.TxtFuncMap()) )
    -

    and a function can even be

    +

    and a function can even be explicitly overridden.

    -explicitly overridden. +(show)

    This would override a function foo and foo2 in sprigx from foo and foo2 from sprig, but leave all other sprig functions untouched.

    @@ -789,19 +827,19 @@ var txtTpl *template.Template = template. 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"], + }, + ), + ) )
    @@ -816,27 +854,39 @@ var txtTpl *template.Template = template.

    Expect this list to grow over time, and potentially more frequently than the sprigx functions.

    -

    3.1. System/OS/Platform

    +

    3.1. Operating System

    -

    3.1.1. sysArch

    +

    3.1.1. osHostname

    +
    +

    osHostname simply wraps and returns the result of calling os.Hostname.

    +
    +
    +

    As such, it comes with the same caveats - it’s possible for it to error, and it isn’t guaranteed to be an FQDN — it will be precisely/exactly whatever the kernel’s hostname is set as.

    +
    +
    +
    +
    +

    3.2. System/Platform/Architecture

    +
    +

    3.2.1. sysArch

    Returns the runtime.GOARCH constant.

    -

    3.1.4. sysRuntime

    +

    3.2.4. sysRuntime

    This function returns a map[string]string of various information from the runtime stdlib library.

    @@ -926,14 +976,14 @@ var txtTpl *template.Template = template.
    -

    3.2. Paths

    +

    3.3. Paths

    -

    3.2.1. Generic

    +

    3.3.1. Generic

    These operate similar to the path stdlib library and use a fixed / path separator.

    -
    3.2.1.1. pathJoin
    +
    3.3.1.1. pathJoin

    pathJoin operates exactly like path.Join in stdlib.

    @@ -945,7 +995,7 @@ var txtTpl *template.Template = template.
    -

    If you are joining paths in a pipeline, you almost assuredly want pathPipeJoin or pathSlicePipeJoin instead.

    +

    If you are joining paths in a pipeline, you almost assuredly want pathPipeJoin or pathSlicePipeJoin instead unless you are explicitly appending a pipeline result to a path.

    @@ -970,7 +1020,7 @@ var txtTpl *template.Template = template.
    -
    3.2.1.2. pathPipeJoin
    +
    3.3.1.2. pathPipeJoin

    pathPipeJoin operates like pathJoin with one deviation: the root/base path is expected to be last in the arguments.

    @@ -997,7 +1047,7 @@ var txtTpl *template.Template = template.
    -
    3.2.1.3. pathSliceJoin
    +
    3.3.1.3. pathSliceJoin

    pathSliceJoin joins a slice of path segment strings ([]string) instead of a variadic sequence of strings.

    @@ -1035,7 +1085,7 @@ a/b/c
    -
    3.2.1.4. pathSlicePipeJoin
    +
    3.3.1.4. pathSlicePipeJoin

    pathSlicePipeJoin operates like pathPipeJoin in that it is suitable for pipeline use in which the root/base path is passed in from the pipeline, but it is like pathSliceJoin in that it then also accepts a slice of path segments ([]string) to append to that base path.

    @@ -1072,7 +1122,7 @@ a/b/c
    -
    3.2.1.5. pathSubJoin
    +
    3.3.1.5. pathSubJoin

    pathSubJoin operates like pathJoin but it expects an explicit root/base path.

    @@ -1099,7 +1149,7 @@ a/b/c
    -

    3.2.2. OS/Platform-Tailored

    +

    3.3.2. OS/Platform-Tailored

    These operate similar to the path/filepath stdlib library, and use the OS-specific os.PathSeparator.

    @@ -1121,7 +1171,7 @@ a/b/c
    -
    3.2.2.1. osPathJoin
    +
    3.3.2.1. osPathJoin

    osPathJoin operates exactly like path/filepath.Join in stdlib.

    @@ -1133,7 +1183,7 @@ a/b/c
    -

    If you are joining paths in a pipeline, you almost assuredly want osPathPipeJoin or osPathSlicePipeJoin instead.

    +

    If you are joining paths in a pipeline, you almost assuredly want osPathPipeJoin or osPathSlicePipeJoin instead unless you are explicitly appending a pipeline result to a path.

    @@ -1189,7 +1239,7 @@ C:/a/b/c
    -
    3.2.2.2. osPathPipeJoin
    +
    3.3.2.2. osPathPipeJoin

    osPathPipeJoin operates like pathPipeJoin (except using OS-specific path separators).

    @@ -1243,7 +1293,7 @@ C:/a/b/c
    -
    3.2.2.3. osPathSep
    +
    3.3.2.3. osPathSep

    osPathSep returns the os.PathSeparator for this OS.

    @@ -1287,7 +1337,7 @@ C:/a/b/c
    -
    3.2.2.4. osPathSliceJoin
    +
    3.3.2.4. osPathSliceJoin

    osPathSliceJoin operates like pathSliceJoin but with OS-specific path separators.

    @@ -1352,7 +1402,7 @@ a/b/c
    -
    3.2.2.5. osPathSlicePipeJoin
    +
    3.3.2.5. osPathSlicePipeJoin

    osPathSlicePipeJoin operates like pathSlicePipeJoin but with OS-specific separators.

    @@ -1415,7 +1465,7 @@ a/b/c
    -
    3.2.2.6. osPathSubJoin
    +
    3.3.2.6. osPathSubJoin

    osPathSubJoin operates like pathSubJoin but with OS-specific separators.

    @@ -1470,15 +1520,29 @@ a/b/c
    -

    3.3. Strings

    +

    3.4. Strings

    -

    3.3.1. extIndent

    +

    3.4.1. extIndent

    extIndent allows for a MUCH more flexible indenter than the sprig indent function.

    It works with both Windows (\r\n) and POSIX (\n) linebreaks.

    +
    + + + + + +
    +
    Tip
    +
    +
    +

    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:

    @@ -1514,6 +1578,15 @@ a/b/c
    +
    +

    3.5. Debugging

    +
    +

    3.5.1. dump

    +
    +

    The dump function calls the Sdump function from go-spew (github.com/davecgh/go-spew/spew) for whatever object(s) is/are passed to it.

    +
    +
    +
    @@ -1525,7 +1598,7 @@ a/b/c diff --git a/tplx/sprigx/README.md b/tplx/sprigx/README.md index 74dbde9..fd7effd 100644 --- a/tplx/sprigx/README.md +++ b/tplx/sprigx/README.md @@ -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 +() or the directory +landing page +(), +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 `