Squiggly

URL & text helpers

relURL, absURL, markdownify, emojify — for sites that emit HTML.

These helpers cover the common things a static site generator wants — they’re the reason juicer ships with a data map containing baseURL and link. If you’re using squiggly as a generic template engine outside that context, you may not need them.

FunctionArityWhat
relURL1Site-relative URL (prepends the renderer’s baseURL.path)
absURL1Absolute URL (prepends baseURL.base + baseURL.path)
urlEscape1Percent-encode for use in URL paths
markdownify1Render a markdown string to HTML (uses io.github.edadma.markdown)
emojify1Substitute :smile: → 😄 (uses io.github.edadma.emoji)

Examples

{{ '/getting-started/' | relURL }}        /docs/getting-started/
{{ '/getting-started/' | absURL }}        https://example.com/docs/getting-started/

{{ 'Hello **world**' | markdownify }}     Hello <strong>world</strong>

{{ ':rocket: shipped!' | emojify }}       🚀 shipped!

How relURL / absURL find baseURL

These read con.renderer.data("baseURL") — a BaseURL(base: String, path: String) value the host application puts in the renderer’s data map at construction time:

import io.github.edadma.squiggly.BaseURL

val renderer = new TemplateRenderer(
  data = Map(
    "baseURL" -> BaseURL("https://example.com", "/docs"),
  ),
)

If your data doesn’t supply this, relURL / absURL will throw at template evaluation. Skip them and write the URLs out directly if you don’t need site-rooting.