Useful template functions for Go templates.


Sprig: Template functions for Go templates

GoDoc Go Report Card Stability: Sustained

The Go language comes with a built-in template language, but not very many template functions. Sprig is a library that provides more than 100 commonly used template functions.

It is inspired by the template functions found in Twig and in various JavaScript libraries, such as underscore.js.


Sprig leverages mergo to handle merges. In its v0.3.9 release there was a behavior change that impacts merging template functions in sprig. It is currently recommended to use v0.3.8 of that package. Using v0.3.9 will cause sprig tests to fail. The issue in mergo is tracked at

Package Versions

There are two active major versions of the sprig package.

  • v3 is currently stable release series on the master branch. The Go API should remain compatible with v2, the current stable version. Behavior change behind some functions is the reason for the new major version.
  • v2 is the previous stable release series. It has been more than three years since the initial release of v2. You can read the documentation and see the code on the release-2 branch. Bug fixes to this major version will continue for some time.


Template developers: Please use Sprig's function documentation for detailed instructions and code snippets for the >100 template functions available.

Go developers: If you'd like to include Sprig as a library in your program, our API documentation is available at

For standard usage, read on.

Load the Sprig library

To load the Sprig FuncMap:

import (

// This example illustrates that the FuncMap *must* be set before the
// templates themselves are loaded.
tpl := template.Must(

Calling the functions inside of templates

By convention, all functions are lowercase. This seems to follow the Go idiom for template functions (as opposed to template methods, which are TitleCase). For example, this:

{{ "hello!" | upper | repeat 5 }}

produces this:


Principles Driving Our Function Selection

We followed these principles to decide which functions to add and how to implement them:

  • Use template functions to build layout. The following types of operations are within the domain of template functions:
    • Formatting
    • Layout
    • Simple type conversions
    • Utilities that assist in handling common formatting and layout needs (e.g. arithmetic)
  • Template functions should not return errors unless there is no way to print a sensible value. For example, converting a string to an integer should not produce an error if conversion fails. Instead, it should display a default value.
  • Simple math is necessary for grid layouts, pagers, and so on. Complex math (anything other than arithmetic) should be done outside of templates.
  • Template functions only deal with the data passed into them. They never retrieve data from a source.
  • Finally, do not override core Go template functions.
  • Please Fix Sprig Compatibility with Semver!

    Please Fix Sprig Compatibility with Semver!

    @mattfarina Can you please update sprig to be compatible with the latest Masterminds/semver changes here:

    Running go get -u now returns the following error: ......\\Masterminds\sprig\semver.go:22:2: cannot use semver.Version as type *semver.Version in return argument

    semver.Version now needs to be a non-pointer, and semver_test.go needs to be updated to play nicely with this data type change.

    We have golang applications that haven't migrated to go-modules yet, and that use sprig as a dependency. Can you please fix this compilation error so that our own downstream builds will succeed?



    opened by eparziale 13
  • dict merge doesn't create a deep copy

    dict merge doesn't create a deep copy

    I have a case where I want a template to take an input dictionary and produce a copy, omitting a few keys at various levels deep in the hierarchy (in this helm chart).

    I ran into a snare, where I didn't realize that after merging two dictionaries, editing the merged dictionary can modify the originals:

    {{- $values := pick .Values "auth" "other"}}
    {{- /* trim secret values. Update here if new secrets are added! */ -}}
    {{- /* make a copy of values.auth to avoid modifying the original */ -}}
    {{- $_ := set $values "auth" (merge dict .Values.auth) }}
    {{- $_ := set $values.auth "state" (omit $values.auth.state "cryptoKey") }}

    Without that set $values "auth" (merge dict .Values.auth), the subsequent set $values.auth "state" would modify the original .Values.auth.state, which I found surprising.

    Is there an existing mechanism to produce a deep copy of a dict, to ensure the original doesn't get modified?

    opened by minrk 12
  • Add KeyUsageCertSign to genSelfSignedCert

    Add KeyUsageCertSign to genSelfSignedCert

    Closes Masterminds/sprig#95 (selfSignedCert cannot verify itself)

    If it is intentional to leave the key usage out, we can discuss it here. Basically, let a self signed cert verify itself.

    opened by iluminae 11
  • mergeOverwrite mutates objects it shouldn't

    mergeOverwrite mutates objects it shouldn't

    I'm using helm which depends on sprig. I wrote a simple fiddle which includes the helm template I'm testing with, as well as some go code that emulates how helm parses the template. You can see it here

    So I've got two objects, $app and $deployments, and if I run mergeOverwrite (dict) $app $deployments I would expect the new dict to first be mutated with the contents of $app and then with the contents of $deployments. But it seems that values from $deployments are being written into $app (as well as the new dict)

    opened by chrisjohnson 10
  • provide a deepCopy() function

    provide a deepCopy() function

    Without deepCopy(), Helm will be unusable for certain fairly simple tasks because of #120 : You cannot repeatedly use merge with the same "base" dict as the first argument unless you can tolerate that that dict will be modified every time. deepCopy() would avoid this.

    opened by multi-io 10
  • Add float64 arithmetic

    Add float64 arithmetic

    Add float64 arithmetic functions. For clarity, these functions all have the "f" suffix. To avoid precision errors, all floats are converted to a decimal representation value using shopspring/decimal before calculating.

    opened by andrewmostello 8
  • Merge function does not overwrite if new value is falsy

    Merge function does not overwrite if new value is falsy

    Given the following code:

    {{ dict "foo" "bar" | merge (dict "foo" "abc") | toPrettyJson }}

    The output is as expected:

      "foo": "abc"

    But if the second dict's key is falsy, the value is not overwritten:

    {{ dict "foo" "bar" | merge (dict "foo" 0) | toPrettyJson }}

    Results in:

      "foo": "bar"

    Any falsy value will be skipped:

    {{ dict "foo" "bar" | merge (dict "foo" 0) | toPrettyJson }}
    {{ dict "foo" "bar" | merge (dict "foo" "") | toPrettyJson }}
    {{ dict "foo" "bar" | merge (dict "foo" false) | toPrettyJson }}

    This is not the behavior of Javascript's Object.assign:

    Object.assign({}, {foo: "bar"}, {foo: 0}) # <-- {foo: 0}

    Sprig's behavior feels extremely counter-intuitive. When I'm merging dicts, if a key has a value assigned, that's the value I care about. It's language-specific falsyness feels irrelevant in this context.

    opened by jcheroske 8
  • can indent work on multi-line template definition?

    can indent work on multi-line template definition?


    {{- define "foobar" }}
      bar: baz
    {{- end }}
    {{- template "foobar" . | indent 2 }}

    I'd like to get:

        bar: baz

    Given the above, I get:

    executing "test" at <2>: wrong type for value; expected string; got map[string]interface {}

    Using {{- template "foobar" . | toString | indent 2 }} I get:

      bar: baz

    Meaning the line(s) never get indented. Even doing {{ template "foobar" . | join "_" | indent 2 }} results in the above, so clearly piping after template isn't working as I hoped it would.

    Are there any ways to solve this?

    opened by JeanMertz 8
  • Surface cryptographically secure random strings from goutils

    Surface cryptographically secure random strings from goutils

    This PR surfaces the random string functions that utilize crypto/rand that were added to goutils here: This will allow Go templates to utilize random strings that have been generated in a cryptographically secure way.

    I made the functions accessible by surfacing them through strings.go. I bounced back and forth between thinking they should be in strings.go and crypto.go a few times. If you think they should be made available via crypto.go instead, just let me know.


    opened by mattlorimor 7
  • Feature Request: Have a

    Feature Request: Have a "slim" version, without dependencies outside stdlib

    Thanks for building this lib! I really like it, but I'd like it even more if it haven't any dependency (outside the standard library)

    Some of the current dependencies are to allow functions I don't care at all on templates, like UUID generation

    For others, the following Go proverb applies:

    "A little copying is better than a than a little dependency"

    Rob Pike

    For example, the xstrings package is imported just because of two functions


    Have a package that have all the functions that doesn't require importing external libraries

    opened by andreynering 7
  • add getHostByName function to resolve dns names to ips

    add getHostByName function to resolve dns names to ips

    Hi guys!

    This is a proposal to add a function to resolve names to IPs. I'm a heavy user of helm and this is useful where you need to render an IP but you don't want to hardcode it in your templates.

    What do you think?

    opened by fcgravalos 6
  • use of

    use of "must" functions is backwards from expectations

    Typically a function prefixed with Must indicates that should a problem occur, the program will panic rather than return an error. Functions with the must prefix are usually used in one of the following situations:

    1. use of constant-like behavior, but cannot be defined as a constant (such as regex parse). The pattern string may be constant, and a single test is enough to assert that no panic will ever occur.

    2. unrecoverable operation, error handling would just add extra boilerplate, and likely not very useful. This is common during application startup.

    Examples of use of must:

    MustCompile is like Compile but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled regular expressions.

    Must is a helper that wraps a call to a function returning (*Template, error) and panics if the error is non-nil. It is intended for use in variable initializations such as


    This is similar in that, there's no "handling" of the condition. If the condition is not met, control is not returned to the caller. The test is just skipped.

    I sprig I see:

    regexFind panics if there is a problem and mustRegexFind returns an error to the template engine if there is a problem.

    opened by ghostsquad 0
  • How to sum a slice in template?

    How to sum a slice in template?

    Is it possible?

    package main
    import (
    func main() {
    	variables := map[string]interface{}{
    		"integers": []int{1, 2, 3},
    	content := `
    		{{ .integers | add }}
    	tpl := template.Must(template.New("t1").Funcs(sprig.FuncMap()).Parse(content))
    	tpl.Execute(os.Stdout, variables)
    opened by rocketspacer 0
  • New `getHostsByAddr` function for rDNS lookups

    New `getHostsByAddr` function for rDNS lookups

    A new getHostsByAddr function for doing reverse DNS lookups.

    It replicates the existing forward DNS function getHostByName, but instead calls net.LookupAddr.

    The intended downstream use case is to allow Grafana Loki to resolve the IPs in log messages.

    Included changes:

    • Test for new function added.
    • Docs for new function added & existing function expanded.
    • Some auto-formatting in functions.go vscode did - no-op change.
    opened by hcooper 0
  • Update version

    Update version

    Fixes CVE-2022-27191

    I don't think this project was affected by the vulnerability since the bug was in the crypto/ssh package and I believe this repo only imports crypto/bcrypt. But useful to get rid of alerts in downstream projects.

    opened by g-gaston 0
  • mustToJson doesnt seem to validate json correctly?

    mustToJson doesnt seem to validate json correctly?

    I used mustToJson against this string: '[{"dfsdfdsf": "sdfsdf"]' It didn't throw an error and returned this: "[{\"dfsdfdsf\": \"sdfsdf\"]"

    opened by red8888 0
  • v3.2.2(Feb 4, 2021)

  • v3.2.1(Feb 4, 2021)

  • v3.2.0(Dec 14, 2020)


    • #211: Added randInt function (thanks @kochurovro)
    • #223: Added fromJson and mustFromJson functions (thanks @mholt)
    • #242: Added a bcrypt function (thanks @robbiet480)
    • #253: Added randBytes function (thanks @MikaelSmith)
    • #254: Added dig function for dicts (thanks @nyarly)
    • #257: Added regexQuoteMeta for quoting regex metadata (thanks @rheaton)
    • #261: Added filepath functions osBase, osDir, osExt, osClean, osIsAbs (thanks @zugl)
    • #268: Added and and all functions for testing conditions (thanks @phuslu)
    • #181: Added float64 arithmetic addf, add1f, subf, divf, mulf, maxf, and minf (thanks @andrewmostello)
    • #265: Added chunk function to split array into smaller arrays (thanks @karelbilek)
    • #270: Extend certificate functions to handle non-RSA keys + add support for ed25519 keys (thanks @misberner)


    • Removed testing and support for Go 1.12. ed25519 support requires Go 1.13 or newer
    • Using semver 3.1.1 and mergo 0.3.11


    • #249: Fix htmlDateInZone example (thanks @spawnia)

    NOTE: The dependency reverted the breaking change in 0.3.9 via 0.3.10 release.

    Source code(tar.gz)
    Source code(zip)
  • v3.1.0(Apr 16, 2020)

    NOTE: The dependency made a behavior change in 0.3.9 that impacts sprig functionality. Do not use sprig with a version newer than 0.3.8.


    • #225: Added support for generating htpasswd hash (thanks @rustycl0ck)
    • #224: Added duration filter (thanks @frebib)
    • #205: Added seq function (thanks @thadc23)


    • #203: Unlambda functions with correct signature (thanks @muesli)
    • #236: Updated the license formatting for GitHub display purposes
    • #238: Updated package dependency versions. Note, mergo not updated to 0.3.9 as it causes a breaking change for sprig. That issue is tracked at


    • #229: Fix seq example in docs (thanks @kalmant)
    Source code(tar.gz)
    Source code(zip)
  • v3.0.2(Dec 13, 2019)


    • #220: Updating to semver v3.0.3 to fix issue with <= ranges
    • #218: fix typo elyptical->elliptic in ecdsa key description (thanks @laverya)
    Source code(tar.gz)
    Source code(zip)
  • v3.0.1(Dec 7, 2019)

  • v3.0.0(Oct 2, 2019)

    Sprig v3 brings some changes while retaining the same Go API. This should enable projects to migrate to v3 with relative ease.

    You might be wondering, why increment the major version if the Go API didn't break? The reason for that is some edge case behavior changed. Most importantly the use of ^ while handling major version 0 use cases with semver. To be cautious, the major version of sprig was incremented to limit the number of surprises.


    • #187: Added durationRound function (thanks @yjp20)
    • #189: Added numerous template functions that return errors rather than panic (thanks @nrvnrvn)
    • #193: Added toRawJson support (thanks @Dean-Coakley)
    • #197: Added get support to dicts (thanks @Dean-Coakley)


    • #186: Moving dependency management to Go modules
    • #186: Updated semver to v3. This has changes in the way ^ is handled
    • #194: Updated documentation on merging and how it copies. Added example using deepCopy
    • #196: trunc now supports negative values (thanks @Dean-Coakley)
    Source code(tar.gz)
    Source code(zip)
  • v2.22.0(Oct 2, 2019)


    • #173: Added getHostByName function to resolve dns names to ips (thanks @fcgravalos)
    • #195: Added deepCopy function for use with dicts


    • Updated merge and mergeOverwrite documentation to explain copying and how to use deepCopy with it
    Source code(tar.gz)
    Source code(zip)
  • v2.21.0(Sep 18, 2019)


    • #122: Added encryptAES/decryptAES functions (thanks @n0madic)
    • #128: Added toDecimal support (thanks @Dean-Coakley)
    • #169: Added list contcat (thanks @astorath)
    • #174: Added deepEqual function (thanks @bonifaido)
    • #170: Added url parse and join functions (thanks @astorath)


    • #171: Updated glide config for Google UUID to v1 and to add ranges to semver and testify


    • #172: Fix semver wildcard example (thanks @piepmatz)
    • #175: Fix dateInZone doc example (thanks @s3than)
    Source code(tar.gz)
    Source code(zip)
  • v2.20.0(Jun 18, 2019)


    • #164: Adding function to get unix epoch for a time (@mattfarina)
    • #166: Adding tests for date_in_zone (@mattfarina)


    • #144: Fix function comments based on best practices from Effective Go (@CodeLingoTeam)
    • #150: Handles pointer type for time.Time in "htmlDate" (@mapreal19)
    • #161, #157, #160, #153, #158, #156, #155, #159, #152 documentation updates (@badeadan)
    Source code(tar.gz)
    Source code(zip)
  • 2.19.0(Mar 2, 2019)

    IMPORTANT: This release reverts a change from 2.18.0

    In the previous release (2.18), we prematurely merged a partial change to the crypto functions that led to creating two sets of crypto functions (I blame @technosophos -- since that's me). This release rolls back that change, and does what was originally intended: It alters the existing crypto functions to use secure random.

    We debated whether this classifies as a change worthy of major revision, but given the proximity to the last release, we have decided that treating 2.18 as a faulty release is the correct course of action. We apologize for any inconvenience.


    • Fix substr panic 35fb796e3ed3869e2df7be0e4fcb5e8b2c425453 (Alexey igrychev)
    • Remove extra period 1eb7729022202c016475c4f4d0cb2c463c22c5fe (Matthew Lorimor)
    • Make random string functions use crypto by default 6ceff26ca2586bda18e788afef093b7d89e70023 (Matthew Lorimor)
    • README edits/fixes/suggestions 08fe136717db5c06a7dd9ee140f9de7070774c78 (Lauri Apple)
    Source code(tar.gz)
    Source code(zip)
  • v2.18.0(Feb 12, 2019)

    Sprig has been updated to accommodate a breaking change to Go Templates' nil handling that was introduced in Go 1.11. Along the way, we added some new functions and updated the documentation in several places.

    A few new functions were added, including:

    • mergeOverwrite
    • cryptographic functions that use secure random (see fe1de1249f2781f5873969508aa1c9a297671ce0)

    All Changes

    • Improve documentation of regexMatch function, resolves #139 90b89cedc86ac45049f89567139100466aa66b4d (Jan Tagscherer)
    • Handle has for nil list 9c108854bc36c8c5a4bc12af6efef00b2093cf81 (Daniel Cohen)
    • Document behaviour of mergeOverwrite fe0dbe93e8c69514fd7e1520237f617219936dd6 (Lukas Rieder)
    • Fix dict merge issue and provide mergeOverwrite .dst .src1 to overwrite from src -> dst 4c59c1250a68e7f7a7e48c54f68c38b5c4c26d20 (Lukas Rieder)
    • doc: adds missing documentation. 4b871e6ee25372506d32433b8500c329feaae404 (Fernandez Ludovic)
    • Replace outdated goutils imports 01893d2f350f3b349e29fd3c5cd49d575293ea04 (Matthew Lorimor)
    • Surface crypto secure random strings from goutils fe1de1249f2781f5873969508aa1c9a297671ce0 (Matthew Lorimor)
    • Handle untyped nil values as paramters to string functions 2b2ec8fad08275e41bc78b9d4ad4938f430e3ef8 (Morten Torkildsen)
    • Fix substr var names and comments d581f80788b5e3493eed4639a3b9b86adf564884 (Dean Coakley)
    • Fix substr documentation 27372034d6d4bc190df568170ea616c97cc4b505 (Dean Coakley)
    Source code(tar.gz)
    Source code(zip)
  • v2.17.1(Jan 3, 2019)

    The 2.17.0 release did not have a version pinned for xstrings, which caused compilation failures when xstrings < 1.2 was used. This adds the correct version string to glide.yaml.

    Source code(tar.gz)
    Source code(zip)
  • v2.17.0(Jan 3, 2019)

    • Update goutils to 1.1.0 4e1125d1400cd9d0d05045013dda46b391f82461 (Matt Butcher)
    • fixes spelling errors... not sure how that happened 4cf188a2b79bcba173ac96e90912cdebcabae153 (marshallford)
    • adds alder32sum function and test 6908fc2d99d9e77185fe248522903e54f8e5ea25 (marshallford)
    • Added kebabcase function ca331a1b276654fa7e74f0b823c1dc57be128a66 (Ilyes512)
    • Fix 'has' documentation e3f2a8519b45e095bdd02b0859346a19942423c9 (dean-coakley)
    • docs(dict): fix typo in pick example dc424f950a9a3fcad8c5175ad9dccb310480b717 (Dustin Specker)
    Source code(tar.gz)
    Source code(zip)
  • v2.16.0(Sep 14, 2018)

    This release adds a few functions and fixes a handful of bugs.

    • Test on go 1.11 49df8097cae92e03cc4e7a167547097d326561ca (Helgi Þormar Þorbjörnsson)
    • Remove duplicated documentation 1d97af137fe1aa7f9e7f46f8d7992b49f96c72fa (Matthew Fisher)
    • add splitn function fccb0b0b31da4884761b9d09598a7e912bd77273 (Helgi Þorbjörnsson)
    • Extract values of dict with values function df393122472a0abccc1046e2cf05173b14a00535 (Lawrence Jones)
    • Minor improvement in code quality - Removed an unreachable piece of code at defaults.go#L26:6 - Resolve formatting issues. 58342415b5b59750f35007a5ac85686478835ac9 (Abhishek Kashyap)
    • Modify panic message for list.slice ae38335fd3a55498f017cfbced1a784221f2ef66 (gongdo)
    • Fix file permissions c5f40b56d466470d82620c466ee189af366e4d44 (gongdo)
    • Fix example for buildCustomCert 7779e0d58432c0df5cf19053fa49a43047c7c4e2 (Tin Lam)
    • Add slice func df28ca70c236b53702a38e6ee30cd24b78e76548 (gongdo)
    • Generate serial number a3bdffd00c74fa4f5e082de7596a7801b273a2bc (Cody Coons)
    Source code(tar.gz)
    Source code(zip)
  • v2.15.0(Apr 3, 2018)

    Two important notes:

    1. This release drops support for Go prior to 1.9. Only supported versions of Go, by the Go Team, are supported by this release. This is due to the use of the Round function on duration introduced in 1.9.
    2. The uuid handling switched to google/uuid due to issues with consuming apps fetching from the tip of master of dependencies. satori/go.uuid has changed it's signature in unreleased code.


    • #68 and #69: Add json helpers to docs (thanks @arunvelsriram)
    • #66: Add ternary function (thanks @binoculars)
    • #67: Allow keys function to take multiple dicts (thanks @binoculars)
    • #89: Added sha1sum to crypto function (thanks @benkeil)
    • #81: Allow customizing Root CA that used by genSignedCert (thanks @chenzhiwei)
    • #92: Add travis testing for go 1.10
    • #93: Adding appveyor config for windows testing


    • #90: Updating to more recent dependencies
    • #73: replace satori/go.uuid with google/uuid (thanks @petterw)


    • #76: Fixed documentation typos (thanks @Thiht)
    • Fixed rounding issue on the ago function. Note, the removes support for Go 1.8 and older
    Source code(tar.gz)
    Source code(zip)
  • v2.14.1(Dec 1, 2017)


    • #60: Fix typo in function name documentation (thanks @neil-ca-moore)
    • #61: Removing line with {{ due to blocking github pages genertion
    • #64: Update the list functions to handle int, string, and other slices for compatibility
    Source code(tar.gz)
    Source code(zip)
  • v2.14.0(Oct 6, 2017)

    This new version of Sprig adds a set of functions for generating and working with SSL certificates.

    • genCA generates an SSL Certificate Authority
    • genSelfSignedCert generates an SSL self-signed certificate
    • genSignedCert generates an SSL certificate and key based on a given CA
    Source code(tar.gz)
    Source code(zip)
  • v2.13.0(Sep 18, 2017)

    This release adds new functions, including:

    • regexMatch, regexFindAll, regexFind, regexReplaceAll, regexReplaceAllLiteral, and regexSplit to work with regular expressions
    • floor, ceil, and round math functions
    • toDate converts a string to a date
    • nindent is just like indent but also prepends a new line
    • ago returns the time from time.Now



    • #40: Added basic regex functionality (thanks @alanquillin)
    • #41: Added ceil floor and round functions (thanks @alanquillin)
    • #48: Added toDate function (thanks @andreynering)
    • #50: Added nindent function (thanks @binoculars)
    • #46: Added ago function (thanks @slayer)


    • #51: Updated godocs to include new string functions (thanks @curtisallen)
    • #49: Added ability to merge multiple dicts (thanks @binoculars)
    Source code(tar.gz)
    Source code(zip)
  • 2.12.0(May 17, 2017)

    This release adds several new functions:

    • snakecase, camelcase, and shuffle are three new string functions
    • fail allows you to bail out of a template render when conditions are not met


    • Fix links to other markdown docs. 967ad1c93844d1c124a1fdd11e326598c8e0aca5 (Chance Zibolski)
    • Add fail function 3ca3f10200798a630f599982452822bce780331e (Kent Rancourt)
    • Fix minor indentation issues 4776d725fbd3e7dbc33207a421dd27c02ef6f4fe (Luk Burchard)
    • Update glide with new dependencies f5b0ed4a680a0943228155eaf6a77a96ead1bc77 (Matt Butcher)
    • Add 'snakecase', 'camelcase' and 'shuffle' c032c8f5cf387d908b2423816eba0c7284d45c48 (Manfred Touron)
    • Updated documentation on merge. eddf742c44c1b2fc4dc23dc22d3a19afc6579072 (Matt Butcher)
    Source code(tar.gz)
    Source code(zip)
  • 2.10.0(Mar 15, 2017)

    Inspired by the utility library underscore.js, we've added a bunch of new utility functions to Sprig. Many of these are designed to work on dict and list types (and for the time being, on tuple as well).


    • semver and semverCompare were added by popular demand.
    • list replaces tuple
    • join was fixed
    • Added:
      • first
      • last
      • intial
      • rest
      • prepend
      • append
      • toString
      • toStrings
      • sortAlpha
      • reverse
      • coalesce
      • pluck
      • pick
      • compact
      • keys
      • omit
      • uniq
      • has
      • without

    Complete changes:

    Add semver and semverCompare. 23597e5f6ad0e4d590e71314bfd0251a4a3cf849 (Matt Butcher) Add without and has functions. 1f3c30139e7139a65b5d6b7f31284d401e5e2487 (Matt Butcher) Add uniq function. a1c06b6a55acfde86a11947008b0393960879665 (Matt Butcher) Only install glide during 'make setup' if not already installed. 586619b4e928bd3cca0a46dac8ac6f2c003fd66a (Matt Butcher) Add setup target to makefile 5db91714c3ebb01eabc8ae26b7d584d6a01c1d30 (Matt Butcher) Clone the generic map instead of acting directly on it. 10f3ff00763f71fc0a79e770031724db83675929 (Matt Butcher) Refactor into multiple files. 9e5d6d81df8c6208941133daaba1134065a477e8 (Matt Butcher) Add pick and omit functions. 44e3642c7dc1354ad15c53fbe4374af4878e765c (Matt Butcher) Add keys function. 427e90187e0902bc04b64167610f2da7ba26e0e1 (Matt Butcher) Add 'compact' function. 2009c2546db608c737012557c9d3e836468f0423 (Matt Butcher) Add 'pluck' function df7a54437d02c7efc12aeb9a44227ca1ae76f861 (Matt Butcher) Add reverse and coalesce functions. 73a59523c1a8202c02786c296731ef5ce1832ddc (Matt Butcher) Add toString, toStrings, and sortAlpha. df3624ede7d0c68697394da73bf4434bdfce4d3c (Matt Butcher) Add list, first, last, initial, rest, prepend, and append. 3e101afd8a97715f7e0dbd41c9988ad6fcaa2d19 (Matt Butcher) Allow 'join' to take other array/slice types. 713da5382fb1da2b725160e68c0735d3cd196be5 (Matt Butcher)

    Source code(tar.gz)
    Source code(zip)
  • 2.8.0(Dec 21, 2016)

    This release adds two new sets of functions:

    • First, it provides access to several path functions (base, dir, clean, ext, and abs)
    • Second, it adds functions for mutating dictionaries (set, unset, hasKey)
    Source code(tar.gz)
    Source code(zip)
  • 2.6.0(Oct 3, 2016)

  • 2.5.0(Aug 19, 2016)

    Four new functions from the strings package have been exposed as template functions. Following established conventions, we've reversed the order of parameters to better suite template usage:

    {{"$5.00" | trimPrefix "$"}}

    Additionally, new aliases have been added for a few functions that didn't follow the naming conventions. There is now a trimAll (used in preference to trimall) and abbrevBoth (in preference to abbrevboth).

    At the 3.0 release (whenever that happens), trimall and abbrevboth will be removed.

    Source code(tar.gz)
    Source code(zip)
  • 2.4.0(Aug 16, 2016)

    This release adds two functions: until and untilStep. These functions generate integer slices. They are designed to be used for iteration:

    {{range $i, $val := until 5}}{{end}}

    In the above, $i is the index, and $val is the value. Both will iterate from 0 to 4.

    For more control, you may use untilStep. The above can be replicated exactly:

    {{range $i, $val := until 0 5 1}}{{end}}

    untilStep takes three arguments: untilStep $start $end $step:

    • $start: The starting value
    • $end: The end value
    • $step: The increment value

    Here's an example that will produce even numbers less than 10:

    {{range $i, $val := until 0 10 2}}

    The above will produce

    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Jun 21, 2016)

    New functions:

    • cat: Concatenate strings with whitespace separators.
    • replace: Replace parts of a string: replace " " "-" "Me First" renders "Me-First"
    • plural: Format plurals: len "foo" | plural "one foo" "many foos" renders "many foos"
    • indent: Indent blocks of text in a way that is sensitive to "\n" characters.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Apr 21, 2016)

    Experimenting with some new crypto functions for orchestration tasks, we've added a genPrivateKey function. Thanks to @bacongobbler for the pull request.

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Mar 30, 2016)

    This release adds the following:

    • default now prints the default value when it does not receive a value down the pipeline. It is much safer now to do {{.Foo | default "bar"}}.
    • Added accessors for "hermetic" functions. These return only functions that, when given the same input, produce the same output.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Mar 29, 2016)

    This release adds a number of new functions:

    • min complements max (formerly biggest)
    • empty indicates that a value is the empty value for its type
    • tuple creates a tuple inside of a template: {{$t := tuple "a", "b" "c"}}
    • dict creates a dictionary inside of a template {{$d := dict "key1" "val1" "key2" "val2"}}
    • Date formatters have been added for HTML dates (as used in date input fields)
    • Integer math functions can convert from a number of types, including string (via strconv.ParseInt).

    Because we switched from int to int64 as the return value for all integer math functions, the library's major version number has been incremented.

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Feb 3, 2016)

    This release features a few improvements.

    • Added quote and squote functions for quoting strings.
    • Addedb32enc and b32dec for Base32 encoding and decoding.
    • add now takes varargs: {{ add 1 2 3 }}
    • biggest now takes varargs: {{ biggest 5 6 4 }}
    • README is updated

    Our tests indicate that making functions variadic seems to be backward compatible, but we're only doing a few this release in case there are some use cases we hadn't thought of.

    Source code(tar.gz)
    Source code(zip)
Go templates invoked as functions

Package tmplfunc provides an extension of Go templates in which templates can be invoked as if they were functions. See the package documentation for

Russ Cox 137 Jul 4, 2022
Wrapper package for Go's template/html to allow for easy file-based template inheritance.

Extemplate Extemplate is a small wrapper package around html/template to allow for easy file-based template inheritance. File: templates/parent.tmpl <

Danny van Kooten 50 Jul 31, 2022
Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application.

goview Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application. Contents Inst

foolin 292 Aug 2, 2022
Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

quicktemplate A fast, powerful, yet easy to use template engine for Go. Inspired by the Mako templates philosophy. Features Extremely fast. Templates

Aliaksandr Valialkin 2.5k Aug 17, 2022
Simple system for writing HTML/XML as Go code. Better-performing replacement for html/template and text/template

Simple system for writing HTML as Go code. Use normal Go conditionals, loops and functions. Benefit from typing and code analysis. Better performance than templating. Tiny and dependency-free.

Nelo Mitranim 4 Apr 13, 2022
A template to build dynamic web apps quickly using Go, html/template and javascript

gomodest-template A modest template to build dynamic web apps in Go, HTML and sprinkles and spots of javascript. Why ? Build dynamic websites using th

Adnaan Badr 85 Aug 10, 2022
Made from template temporalio/money-transfer-project-template-go

Temporal Go Project Template This is a simple project for demonstrating Temporal with the Go SDK. The full 20 minute guide is here: https://docs.tempo

MarkGorewicz 0 Jan 6, 2022
Go-project-template - Template for a golang project

This is a template repository for golang project Usage Go to github: https://git

KyberNetwork 3 Jul 9, 2022
Go-api-template - A rough template to give you a starting point for your API

Golang API Template This is only a rough template to give you a starting point f

Only Tunes Radio 3 Jan 14, 2022
Api-go-template - A simple Go API template that uses a controller-service based model to build its routes

api-go-template This is a simple Go API template that uses a controller-service

Pedro Espíndula 1 Feb 18, 2022
Programatic document generation as a HTTP service. Render PDFs using LaTeX templates and JSON.

LaTTe Generate PDFs using LaTeX templates and JSON. Try out the demo! Find LaTTe on Docker Hub Table of Contents About Obtaining LaTTe Running & Using

Raphael Reyna 184 Jul 24, 2022
"to be defined" - a really simple way to create text templates with placeholders

tbd "to be defined" A really simple way to create text templates with placeholders. This tool is deliberately simple and trivial, no advanced features

Luca Sepe 20 Aug 6, 2022
Universal JSON, BSON, YAML, CSV, XML converter with templates

Universal JSON, BSON, YAML, CSV, XML translator to ANY format using templates Key features Various input formats (json, bson, yaml, csv, xml) Flexible

Mario 59 Jul 28, 2022
Allows you to fill in variables in your custom project templates.

go-templater The best project templater go-templater lets you use any project template you want and replace the variables with values from the config.

null 0 Nov 6, 2021
Callable Ajax / http requests inside Golang templates

jaco Callable Ajax / http requests inside Golang templates Examples Examples #1 {{ define "content" }} <div id="myTodos"></div> <script>

Joe Gasewicz 0 Dec 5, 2021
Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations

GoSpin Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural co

Miles Croxford 39 Aug 7, 2022
HTML template engine for Go

Ace - HTML template engine for Go Overview Ace is an HTML template engine for Go. This is inspired by Slim and Jade. This is a refinement of Gold. Exa

Keiji Yoshida 818 Jul 2, 2022
Package damsel provides html outlining via css-selectors and common template functionality.

Damsel Markup language featuring html outlining via css-selectors, extensible via pkg html/template and others. Library This package expects to exist

Daniel Skinner 25 Jan 24, 2022
Simple and fast template engine for Go

fasttemplate Simple and fast template engine for Go. Fasttemplate performs only a single task - it substitutes template placeholders with user-defined

Aliaksandr Valialkin 624 Aug 6, 2022