#tera-templates #tera #template #sprig

bin+lib tera-sprig

Sprig Functions for Tera Template Engine

1 unstable release

0.1.0 Aug 8, 2024

#200 in Template engine

Download history 103/week @ 2024-08-07 2/week @ 2024-08-14

105 downloads per month

MIT license

13KB
276 lines

Sprig Functions for Tera Template Engine

Sprig is a list of tempalte functions for Go tempaltes.

This project transplant Sprig to Tera template language.

Strings

Built-ins

  • trim - builtin
  • trimAll(substr)
  • trimSuffix(suffix)
  • trimPrefix(prefix)
  • upper
  • lower
  • title
  • untitle
  • repeat(count)
  • substr(start, len)
  • nospace
  • trunc(len)
  • abbrev(len)
  • abbrevboth(left, maxlen)
  • initials
  • randAlphaNum(len)
  • randAlpha(len)
  • randNumeric(len)
  • randAscii(len)
  • wrap(len)
  • wrapWith(len, sep)
  • contains(substr)
  • hasPrefix(prefix)
  • hasSuffix(suffix)
  • quote
  • squote
  • cat
  • indent(len)
  • nindent(len)
  • replace(from, to)
  • plural(one, more)
  • snakecase
  • camelcase
  • kebabcase
  • swapcase
  • shuffle
  • regexMatch
  • mustRegexMatch
  • regexFindAll
  • mustRegexFindAll
  • regexFind
  • mustRegexFind
  • regexReplaceAll
  • mustRegexReplaceAll
  • regexReplaceAllLiteral
  • mustRegexReplaceAllLiteral
  • regexSplit
  • mustRegexSplit
  • regexQuoteMeta

String Slice Functions

  • join
  • splitList
  • split
  • splitn
  • sortAlpha

Integer Math Functions

  • add
  • add1
  • sub
  • div
  • mod
  • mul
  • max
  • min
  • floor
  • ceil
  • round
  • randint

Dependencies

~8–18MB
~232K SLoC