= SprigX Brent Saner Last rendered {localdatetime} :doctype: book :docinfo: shared :data-uri: :imagesdir: images :sectlinks: :sectnums: :sectnumlevels: 7 :toc: preamble :toc2: left :idprefix: :toclevels: 7 :source-highlighter: rouge :docinfo: shared // BEGIN variable attributes :sprig_ver: 3 :psutil_ver: 4 :mod_me: r00t2.io/goutils :pkg_me: tplx/sprigx :src_root: https://git.r00t2.io :godoc_root: https://pkg.go.dev :sprig_web: https://masterminds.github.io/sprig :mod_sprig: github.com/Masterminds/sprig/v{sprig_ver} :mod_psutil: github.com/shirou/gopsutil/v{psutil_ver} :import_sprig: {mod_sprig} :src_base: {src_root}/r00t2/go_goutils/src/branch/master :src_dir: {src_base}/{pkg_me} :import_me: {mod_me}/{pkg_me} :godoc_me: {godoc_root}/{import_me} :godoc_sprig: {godoc_root}/{import_sprig} // END variable attributes [id="wat"] == What is SprigX? SprigX is a suite of extensions to {sprig_web}/[the `sprig` library^] ({godoc_sprig}[Go docs^]). 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 ({godoc_me}) or the directory landing page ({src_dir}), it may not render correctly. Be sure to view it at properly via {src_dir}/README.adoc[the AsciiDoc rendering^] or by downloading and viewing the {src_dir}/README.html[HTML version^] and/or {src_dir}/README.pdf[PDF version^]. ==== [id="use"] == How do I Use SprigX? The same way you would `sprig`! [%collapsible] .Like this. ==== [source,go,subs="attributes"] ---- package main import ( htmlTplLib "html/template" txtTplLib "text/template" "{import_me}" ) var ( txtTpl *txtTplLib.Template = txtTplLib. New(""). Funcs( sprigx.TxtFuncMap(), ) htmlTpl *htmlTplLib.Template = htmlTplLib. New(""). Funcs( sprigx.HtmlFuncMap(), ) ) ---- ==== They can even be combined/used together. [%collapsible] .Like this. ==== [source,go,subs="attributes"] ---- package main import ( "text/template" "{import_sprig}" "{import_me}" ) var txtTpl *template.Template = template. New(""). Funcs( sprigx.TxtFuncMap(), ). Funcs( sprig.TxtFuncMap(), ) // Or: /* var txtTpl *template.Template = template. New(""). Funcs( sprig.TxtFuncMap(), ). Funcs( sprigx.TxtFuncMap(), ) */ ---- ==== Or, as a convenience, you can simply use the <> and/or <> functions. If a `