Squiggly

Builtins

The bundled template functions — strings, numbers, collections, regex, dates, url/text, debug.

Squiggly ships with a standard library of ~80 template functions in TemplateBuiltin.functions. Pass it (and any additions of your own) to the renderer:

val renderer = new TemplateRenderer(
  functions = TemplateBuiltin.functions ++ myCustomFunctions,
)

Every builtin is callable in three equivalent forms:

{{ trim .name }}              // function-call form
{{ .name | trim }}            // pipe form  (data threads in as last arg)
{{ .name.trim }}              // method form (1-arg only)

Pages below catalog them by category:

  • Strings — case, whitespace, search, slicing, editing, printf
  • Numbers — math, parse/coerce (int / float / bool), formatted output
  • Collections — lists, maps, slicing, map / filter, set ops
  • RegexfindRE with capture groups
  • Datesnow / time / unix / format on java.time
  • URL & text helpersurlize / slugify / markdownify / emojify / jsonStr / querify
  • Debugcontext / print / println

Pages

  • Strings — upper, lower, trim, replace, split, join, printf and friends.
  • Numbers — abs, ceil, floor, round, max, min, sum, int, float, bool, printf.
  • Collections — Operating on lists and maps — head, tail, slice, filter, map, set ops.
  • Regex — findRE for capturing groups across every match.
  • Dates — now, time, unix, format — built on java.time.
  • URL & text helpers — urlize, slugify, urlEncode, querify, jsonStr, markdownify, emojify.
  • Debug — context, print, println — what's actually in scope here?

Search

Esc
to navigate to open Esc to close