github gruntwork-io/boilerplate v0.2.24

latest releases: v0.6.0, v0.6.0-rc1, v0.5.19...
5 years ago

#49: This integrates sprig into boilerplate so that the sprig functions are available in the templates rendered by boilerplate. Note that there are a few boilerplatefunctions that overlap withsprig. Each of these are now documented in the README. As such, starting this release those helpers are deprecated, and will be replaced with the sprig` versions in a future release. Please review the deprecation notes in the README, pasted below for convenience.

Deprecated helpers

These helpers are deprecated. They are currently available for backwards compatibility, but may be removed in future
versions. Please use the alternative supported forms listed in the description.

The following functions overlap with sprig, but have different functionality. There is an equivalent function listed
above under a different name. These point to the boilerplate implementations for backwards compatibility. Please migrate
to using the new naming scheme, as they will be updated to use the sprig versions in future versions of boilerplate.

  • round: In boilerplate, round returns the integer form as opposed to float. E.g {{ round 123.5555 }} will return
    124. The following supported alternative functions are available:
    • roundFloat: The sprig version of round, which supports
      arbitrary decimal rounding. E.g {{ round 123.5555 3 }} returns 123.556. Note that {{ round 123.5555 0 }}
      returns 124.0.
    • roundInt: Another name for the boilerplate version of round. Use this if you would like to keep old behavior.
  • ceil and floor: In boilerplate, ceil and floor return integer forms as opposed to floats. E.g {{ ceil 1.1 }} returns 2, as opposed to 2.0 in the sprig version. The following supported alternative functions are
    available:
    • ceilFloat and floorFloat: The sprig version of ceil and
      floor.
    • ceilInt and floorInt: Another name for the boilerplate version ceil and floor. Use this if you would like to keep old behavior.
  • env: In boilerplate, env supports returning a default value if the environment variable is not defined. The
    following supported alternative functions are available:
    • readEnv: The sprig version of env. This always returns empty
      string if the environment variable is undefined.
    • envWithDefault: Another name for the boilerplate version of env. Use this if you would like to keep old
      behavior.
  • keys: In boilerplate, keys returns the keys of the map in sorted order. The following supported alternative
    functions are available:
    • keysUnordered: The sprig version of keys. This returns the
      list of keys in no particular order, and there is no guarantee that the order of the returned list is consistent.
    • keysSorted: Another name for the boilerplate version of keys. Use this if you would like to keep old
      behavior.
  • replace: In boilerplate, replace only replaces the first occurrence in the string, as opposed to all occurrences
    as in sprig. The following supported alternative functions are available:
    • replaceAll: The sprig version of replace.
    • replaceOne: Another name for the boilerplate version of replace. Use this if you would like to keep old
      behavior.
  • slice: In boilerplate, slice returns a list of numbers in the provided range. E.g {{ slice 1 5 1 }} returns
    the list [1, 2, 3, 4]. The following supported alternative functions are available:
    • sliceList: The sprig version of slice, which returns the
      slice of the given list. E.g {{ slice list n m }} returns list[n:m].
    • numRange: Another name for the boilerplate version of slice. Use this if you would like to keep old
      behavior.
  • trimPrefix and trimSuffix: In boilerplate, trimPrefix and trimSuffix takes the base string first. E.g
    {{ trimPrefix hello-world hello }} returns -world. The following supported alternative functions are available:
    • trimPrefixSprig and trimSuffixSprig: The sprig version of
      trimPrefix and
      trimSuffix. Unlike the boilerplate version, this takes the trim text first so that you can pipeline the trimming. E.g {{ "hello-world" | trimPrefix "hello" }} returns {{ -world }}.
    • trimPrefixBoilerplate and trimSuffixBoilerplate: Another name for the boilerplate versions of trimPrefix
      and trimSuffix. Use this if you would like to keep old behavior.

Don't miss a new boilerplate release

NewReleases is sending notifications on new releases.