<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Squiggly</title>
  <link href="https://edadma.github.io/squiggly/feed.xml" rel="self"/>
  <link href="https://edadma.github.io/squiggly/"/>
  <id>https://edadma.github.io/squiggly/feed.xml</id>
  <updated>2026-05-10T23:04:32.478538713Z</updated>
  <author><name>Ed Maxedon</name></author>
  <entry>
    <title>URL &amp; text helpers</title>
    <link href="https://edadma.github.io/squiggly/builtins/url-and-text/"/>
    <id>https://edadma.github.io/squiggly/builtins/url-and-text/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>relURL, absURL, markdownify, emojify — for sites that emit HTML.</summary>
    <content type="html">&lt;p&gt;These helpers cover the common things a static site generator wants — they’re the reason juicer ships with a &lt;code&gt;data&lt;/code&gt; map containing &lt;code&gt;baseURL&lt;/code&gt; and &lt;code&gt;link&lt;/code&gt;. If you’re using squiggly as a generic template engine outside that context, you may not need them.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;relURL&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Site-relative URL (prepends the renderer’s &lt;code&gt;baseURL.path&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;absURL&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Absolute URL (prepends &lt;code&gt;baseURL.base + baseURL.path&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;urlEscape&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Percent-encode for use in URL paths&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;markdownify&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Render a markdown string to HTML (uses &lt;code&gt;io.github.edadma.markdown&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;emojify&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Substitute &lt;code&gt;:smile:&lt;/code&gt; → 😄 (uses &lt;code&gt;io.github.edadma.emoji&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;/getting-started/&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; relURL &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        /docs/getting-started/
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;/getting-started/&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; absURL &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        https://example.com/docs/getting-started/

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;Hello **world**&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; markdownify &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;     Hello &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;world&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;:rocket: shipped!&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; emojify &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;       🚀 shipped!&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;how-relurl-absurl-find-baseurl&quot;&gt;How &lt;code&gt;relURL&lt;/code&gt; / &lt;code&gt;absURL&lt;/code&gt; find baseURL&lt;/h2&gt;
&lt;p&gt;These read &lt;code&gt;con.renderer.data(&amp;quot;baseURL&amp;quot;)&lt;/code&gt; — a &lt;code&gt;BaseURL(base: String, path: String)&lt;/code&gt; value the host application puts in the renderer’s &lt;code&gt;data&lt;/code&gt; map at construction time:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-keyword&quot;&gt;import&lt;/span&gt; io&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;github&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;edadma&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;squiggly&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-type&quot;&gt;BaseURL&lt;/span&gt;

&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; renderer &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateRenderer&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
  data &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;baseURL&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;BaseURL&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&amp;quot;https://example.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;/docs&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If your data doesn’t supply this, &lt;code&gt;relURL&lt;/code&gt; / &lt;code&gt;absURL&lt;/code&gt; will throw at template evaluation. Skip them and write the URLs out directly if you don’t need site-rooting.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Strings</title>
    <link href="https://edadma.github.io/squiggly/builtins/strings/"/>
    <id>https://edadma.github.io/squiggly/builtins/strings/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>upper, lower, trim, replace, split, join, and friends.</summary>
    <content type="html">&lt;p&gt;The string builtins. All can be called as a function, a pipe target, or (where the arity allows) a method.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;upper&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Uppercase&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;lower&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Lowercase&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;trim&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Strip leading + trailing whitespace&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;length&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Number of characters&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;len&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Alias for &lt;code&gt;length&lt;/code&gt; (works on lists / maps too)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;isEmpty&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;True if length is zero&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;nonEmpty&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;True if length is non-zero&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;reverse&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Reverse the string&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;replace&lt;/code&gt;&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;code&gt;replace s &apos;old&apos; &apos;new&apos;&lt;/code&gt; — every occurrence&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;split&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;split s &apos;sep&apos;&lt;/code&gt; — into a list of strings&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;join&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;join list &apos;sep&apos;&lt;/code&gt; — concatenate with separator&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;startsWith&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;startsWith s &apos;prefix&apos;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;endsWith&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;endsWith s &apos;suffix&apos;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;contains&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;contains s &apos;needle&apos;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;indexOf&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;indexOf s &apos;needle&apos;&lt;/code&gt; — &lt;code&gt;-1&lt;/code&gt; when absent&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;substring&lt;/code&gt;&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;code&gt;substring s start end&lt;/code&gt; — half-open interval&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;repeat&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;repeat s n&lt;/code&gt; — repeat the string n times&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; upper &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                              CSS HOOK
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;author&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; trim &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; lower &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; replace &lt;span class=&quot;hl-string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;-&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;    &amp;quot;ed-maxedon&amp;quot;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; split &lt;span class=&quot;hl-string&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; length &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                 number of lines

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; endsWith &lt;span class=&quot;hl-string&quot;&gt;&apos;.md&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;               markdown file
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; contains &lt;span class=&quot;hl-string&quot;&gt;&apos;&amp;lt;!--more--&amp;gt;&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;           has a manual summary cut

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; split &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;csv&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;,&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; join &lt;span class=&quot;hl-string&quot;&gt;&apos; / &apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                 reformat&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Regex</title>
    <link href="https://edadma.github.io/squiggly/builtins/regex/"/>
    <id>https://edadma.github.io/squiggly/builtins/regex/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>matchRE, findRE, replaceRE for pattern-based string operations.</summary>
    <content type="html">&lt;p&gt;Regex builtins use Java’s &lt;code&gt;java.util.regex.Pattern&lt;/code&gt; syntax (the same flavor as Scala’s &lt;code&gt;Regex&lt;/code&gt;).&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;matchRE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;matchRE s pattern&lt;/code&gt; — true if the entire string matches&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;findRE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;findRE s pattern&lt;/code&gt; — first match’s groups (a list); empty list when no match&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;findAllRE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;findAllRE s pattern&lt;/code&gt; — list of group-lists, one per match&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;replaceRE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;code&gt;replaceRE s pattern replacement&lt;/code&gt; — every match replaced; &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt;, &lt;code&gt;$0&lt;/code&gt; work in &lt;code&gt;replacement&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;splitRE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;splitRE s pattern&lt;/code&gt; — split on every match, returning the in-between pieces&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;h3 id=&quot;validate&quot;&gt;Validate&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; matchRE &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;^[^@]+@[^@]+&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;[^@]+$&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  valid
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  invalid
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;extract-groups&quot;&gt;Extract groups&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; ymd &lt;span class=&quot;hl-punctuation&quot;&gt;:&lt;/span&gt;= findRE &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;^(&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;{4})-(&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;{2})-(&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;{2})$&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-comment&quot;&gt;// ymd is a list: [whole-match, year, month, day] }}&lt;/span&gt;
{{ &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; ymd &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; nonEmpty &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  year = &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; ymd&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;, month = &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; ymd&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;, day = &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; ymd&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The capture-group behavior was restored in 0.2.3 — earlier 0.2.x lost groups.&lt;/p&gt;
&lt;h3 id=&quot;find-every-match&quot;&gt;Find every match&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; m &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; findAllRE &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;[([^&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;]]+)&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;]&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; m&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        // each capture group&apos;s text
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;replace&quot;&gt;Replace&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; replaceRE &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;b(&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;w+) - (&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;w+)&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;b&apos;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;$1 — $2&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;split&quot;&gt;Split&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; chunk &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; splitRE &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;s+&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; chunk &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Quickstart</title>
    <link href="https://edadma.github.io/squiggly/getting-started/quickstart/"/>
    <id>https://edadma.github.io/squiggly/getting-started/quickstart/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>Parse a template, render it against some data, in three lines.</summary>
    <content type="html">&lt;p&gt;A template is a string of HTML or text with &lt;code&gt;{{ … }}&lt;/code&gt; interpolation. Squiggly’s API has two halves:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;TemplateParser&lt;/code&gt;&lt;/strong&gt; — parses a template string into an AST.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;TemplateRenderer&lt;/code&gt;&lt;/strong&gt; — renders an AST against a data shape.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-keyword&quot;&gt;import&lt;/span&gt; io&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;github&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;edadma&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;squiggly&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;_

&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; parser   &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateParser&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;default
&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; renderer &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateRenderer&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; ast &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; parser&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;parse&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;&amp;quot;&amp;quot;{{ for p &amp;lt;- .pages }}&lt;/span&gt;
&lt;span class=&quot;hl-string&quot;&gt;    |  - {{ p.title | upper }}&lt;/span&gt;
&lt;span class=&quot;hl-string&quot;&gt;    |{{ end }}&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;stripMargin&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; data &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;pages&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;hl-type&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;hl-type&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;Goodbye&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;

renderer&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;render&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt; ast&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl-comment&quot;&gt;// =&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-comment&quot;&gt;//   - HELLO&lt;/span&gt;
&lt;span class=&quot;hl-comment&quot;&gt;//   - GOODBYE&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s it. The any-data shape (&lt;code&gt;Map[String, Any]&lt;/code&gt; / &lt;code&gt;List[Any]&lt;/code&gt; / scalars) is what &lt;code&gt;data&lt;/code&gt; is — anything that can be a YAML / TOML / JSON document fits without translation.&lt;/p&gt;
&lt;h2 id=&quot;customizing-the-renderer&quot;&gt;Customizing the renderer&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;TemplateRenderer&lt;/code&gt; takes four optional parameters:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Parameter&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;partials&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A &lt;code&gt;TemplateLoader&lt;/code&gt; (&lt;code&gt;String =&amp;gt; Option[TemplateAST]&lt;/code&gt;) used by &lt;code&gt;{{ partial &apos;name&apos; . }}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;blocks&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Mutable &lt;code&gt;HashMap[String, TemplateAST]&lt;/code&gt; used by &lt;code&gt;{{ define name }}&lt;/code&gt; / &lt;code&gt;{{ block name . }}&lt;/code&gt; — pass an existing one if you want to share named blocks across multiple renders&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;functions&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Map of custom template functions to merge with the builtin set&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;data&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Renderer-wide data — read inside template functions via &lt;code&gt;con.renderer.data&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; renderer &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateRenderer&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;
  partials  &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; name &lt;span class=&quot;hl-keyword&quot;&gt;=&amp;gt;&lt;/span&gt; myPartialMap&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
  functions &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateBuiltin&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;functions &lt;span class=&quot;hl-keyword&quot;&gt;++&lt;/span&gt; myFunctions&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt;
  data      &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&amp;quot;siteUrl&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;https://example.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;going-deeper&quot;&gt;Going deeper&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/squiggly/syntax/&quot;&gt;Syntax&lt;/a&gt; — every form the parser accepts (substitution, control flow, partials, blocks, pipe filters, expressions).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/squiggly/builtins/&quot;&gt;Builtins&lt;/a&gt; — the bundled string / list / regex / date functions.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  <entry>
    <title>Installation</title>
    <link href="https://edadma.github.io/squiggly/getting-started/installation/"/>
    <id>https://edadma.github.io/squiggly/getting-started/installation/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>Add squiggly as an sbt dependency.</summary>
    <content type="html">&lt;p&gt;Squiggly is published on Maven Central as &lt;code&gt;io.github.edadma:squiggly&lt;/code&gt;. Cross-built for JVM, Scala.js, and Scala Native on Scala 3.&lt;/p&gt;
&lt;h2 id=&quot;sbt&quot;&gt;sbt&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;libraryDependencies &lt;span class=&quot;hl-keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;io.github.edadma&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;%%%&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;squiggly&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;0.2.3&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;%%%&lt;/code&gt; selects the right artifact for your active platform. If you only need the JVM build, &lt;code&gt;%%&lt;/code&gt; works too.&lt;/p&gt;
&lt;h2 id=&quot;scala-cli&quot;&gt;scala-cli&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-comment&quot;&gt;//&amp;gt; using dep &amp;quot;io.github.edadma::squiggly:0.2.3&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;mill&quot;&gt;Mill&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;ivy&lt;span class=&quot;hl-string&quot;&gt;&amp;quot;io.github.edadma::squiggly:0.2.3&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;requirements&quot;&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scala 3.8.3&lt;/strong&gt; — squiggly is Scala 3 only. There is no 2.13 backport.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JVM 17+&lt;/strong&gt; for the JVM target.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Node 20+&lt;/strong&gt; for the Scala.js target.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clang&lt;/strong&gt; for the Scala Native target.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  <entry>
    <title>Expressions</title>
    <link href="https://edadma.github.io/squiggly/syntax/expressions/"/>
    <id>https://edadma.github.io/squiggly/syntax/expressions/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>Substitution, field access, operators, function calls, pipes.</summary>
    <content type="html">&lt;p&gt;Inside &lt;code&gt;{{ … }}&lt;/code&gt; you can put any expression. The result is converted to a string and emitted at that position in the output.&lt;/p&gt;
&lt;h2 id=&quot;substitution&quot;&gt;Substitution&lt;/h2&gt;
&lt;p&gt;The simplest expression is a field access. The &lt;code&gt;.&lt;/code&gt; prefix references the current data context:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.title&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&apos;some key&apos;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bare identifiers (no leading &lt;code&gt;.&lt;/code&gt;) reference local variables or template
parameters.&lt;/p&gt;
&lt;h2 id=&quot;literals&quot;&gt;Literals&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;a string&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;      single-quoted
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&amp;quot;a string&amp;quot;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;      double-quoted (interchangeable)
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;42&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;              integer
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;3.14&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;            floating point
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-variable&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;            boolean
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-variable&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-variable&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;operators&quot;&gt;Operators&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Class&lt;/th&gt;&lt;th&gt;Operators&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Arithmetic&lt;/td&gt;&lt;td&gt;&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Comparison&lt;/td&gt;&lt;td&gt;&lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Logical&lt;/td&gt;&lt;td&gt;&lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, &lt;code&gt;not&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;String&lt;/td&gt;&lt;td&gt;&lt;code&gt;+&lt;/code&gt; (concatenation)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Membership&lt;/td&gt;&lt;td&gt;&lt;code&gt;in&lt;/code&gt; (e.g., &lt;code&gt;&apos;foo&apos; in .tags&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  Many.
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;function-calls&quot;&gt;Function calls&lt;/h2&gt;
&lt;p&gt;Any function in the renderer’s function map can be called directly. Most builtins are 1-arity and accept a pipe target.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; upper &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; len &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;pages&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; replace &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;foo&apos;&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;bar&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;pipe-syntax&quot;&gt;Pipe syntax&lt;/h2&gt;
&lt;p&gt;The pipe operator &lt;code&gt;|&lt;/code&gt; threads the previous value as the &lt;em&gt;first&lt;/em&gt; argument
to the next function. These two are equivalent:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; upper &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; trim &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;trim&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;upper &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pipes read left-to-right, which is friendlier than nested calls when you have several transforms.&lt;/p&gt;
&lt;h2 id=&quot;method-style-calls&quot;&gt;Method-style calls&lt;/h2&gt;
&lt;p&gt;Any 1-arity function can be invoked as a method on its receiver:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name.upper.trim&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; upper &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; trim &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;trim&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;upper &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All three render the same output.&lt;/p&gt;
&lt;h2 id=&quot;grouping&quot;&gt;Grouping&lt;/h2&gt;
&lt;p&gt;Parentheses group expressions and force evaluation order:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;published&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;…&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;conditional-expression&quot;&gt;Conditional expression&lt;/h2&gt;
&lt;p&gt;The C-style ternary, written with &lt;code&gt;then&lt;/code&gt; / &lt;code&gt;else&lt;/code&gt; keywords for readability:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;draft&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;DRAFT&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;LIVE&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Different from the &lt;em&gt;block-form&lt;/em&gt; &lt;code&gt;{{ if … }} … {{ end }}&lt;/code&gt; — see &lt;a href=&quot;/squiggly/squiggly/syntax/control-flow/&quot;&gt;Control flow&lt;/a&gt;.)&lt;/p&gt;
&lt;h2 id=&quot;truthiness&quot;&gt;Truthiness&lt;/h2&gt;
&lt;p&gt;A value is &lt;strong&gt;truthy&lt;/strong&gt; unless it’s:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;null&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the empty string &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the empty list / map&lt;/li&gt;
&lt;li&gt;the integer &lt;code&gt;0&lt;/code&gt; or float &lt;code&gt;0.0&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, and &lt;code&gt;not&lt;/code&gt; all use this definition.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Debug</title>
    <link href="https://edadma.github.io/squiggly/builtins/debug/"/>
    <id>https://edadma.github.io/squiggly/builtins/debug/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>context, type — what&apos;s actually in scope here?</summary>
    <content type="html">&lt;p&gt;Two functions you reach for when a template isn’t rendering what you thought it would.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;context&lt;/code&gt;&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;Print the entire current data context to the renderer’s output stream&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;type&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Return the runtime type name of an expression’s value (e.g. &lt;code&gt;&amp;quot;java.lang.String&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;scala.collection.immutable.Map&amp;quot;&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; context &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;…dumps everything the template can see at this point — the current &lt;code&gt;data&lt;/code&gt;, plus locals introduced by enclosing &lt;code&gt;with&lt;/code&gt; / &lt;code&gt;for&lt;/code&gt; / &lt;code&gt;:=&lt;/code&gt; blocks. Useful when a field reference unexpectedly renders empty: drop a &lt;code&gt;{{ context }}&lt;/code&gt; above it and check whether the field is actually there.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; type &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; type &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.tags&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; type &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.weight&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Tells you what concrete class the value is. Helps when an &lt;code&gt;if&lt;/code&gt; is taking the wrong branch (because, say, your “boolean” is actually a string &lt;code&gt;&amp;quot;false&amp;quot;&lt;/code&gt; from frontmatter).&lt;/p&gt;
&lt;h2 id=&quot;when-you-need-more&quot;&gt;When you need more&lt;/h2&gt;
&lt;p&gt;For non-trivial debugging, it’s often easier to print from Scala — write a small &lt;code&gt;inspect: Any =&amp;gt; Any&lt;/code&gt; template function that &lt;code&gt;println&lt;/code&gt;s its argument and returns it unchanged, then drop &lt;code&gt;{{ inspect .x }}&lt;/code&gt; wherever you want a peek. Squiggly’s data-context model means everything in scope is just a Scala value; you have full freedom to instrument it from outside the template.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Dates</title>
    <link href="https://edadma.github.io/squiggly/builtins/dates/"/>
    <id>https://edadma.github.io/squiggly/builtins/dates/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>now, dateFormat, dateParse — built on java.time.</summary>
    <content type="html">&lt;p&gt;Date/time builtins use Java’s &lt;code&gt;java.time&lt;/code&gt; API. Available on JVM and Scala Native (which has a &lt;code&gt;java.time&lt;/code&gt; shim) — Scala.js works too via &lt;code&gt;scala-java-time&lt;/code&gt; if you pull it in as a dep.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;now&lt;/code&gt;&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;Current &lt;code&gt;LocalDateTime&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;dateFormat&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;dateFormat date pattern&lt;/code&gt; — render a date with a &lt;code&gt;DateTimeFormatter&lt;/code&gt; pattern&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;dateParse&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;dateParse string pattern&lt;/code&gt; — parse a string into a date&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; now &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; dateFormat &lt;span class=&quot;hl-string&quot;&gt;&apos;yyyy-MM-dd&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                today
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.date&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; dateFormat &lt;span class=&quot;hl-string&quot;&gt;&apos;MMMM d, yyyy&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        December 7, 2025
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.date&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; dateFormat &lt;span class=&quot;hl-string&quot;&gt;&apos;EEEE&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                day of week

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; d &lt;span class=&quot;hl-punctuation&quot;&gt;:&lt;/span&gt;= dateParse &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;feed.pubDate&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;EEE, dd MMM yyyy HH:mm:ss Z&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; d &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; dateFormat &lt;span class=&quot;hl-string&quot;&gt;&apos;yyyy-MM-dd&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                   re-format&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;pattern-reference&quot;&gt;Pattern reference&lt;/h2&gt;
&lt;p&gt;The patterns are standard &lt;code&gt;java.time.format.DateTimeFormatter&lt;/code&gt; patterns — see the &lt;a href=&quot;https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/format/DateTimeFormatter.html#patterns&quot;&gt;JDK reference&lt;/a&gt; for the full grammar. Common pieces:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Pattern&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;th&gt;Example&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;yyyy&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Four-digit year&lt;/td&gt;&lt;td&gt;&lt;code&gt;2025&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;MM&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Zero-padded month&lt;/td&gt;&lt;td&gt;&lt;code&gt;07&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;MMM&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Short month name&lt;/td&gt;&lt;td&gt;&lt;code&gt;Jul&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;MMMM&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Full month name&lt;/td&gt;&lt;td&gt;&lt;code&gt;July&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;dd&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Zero-padded day&lt;/td&gt;&lt;td&gt;&lt;code&gt;02&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Day, no padding&lt;/td&gt;&lt;td&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;EEE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Short weekday&lt;/td&gt;&lt;td&gt;&lt;code&gt;Mon&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;EEEE&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Full weekday&lt;/td&gt;&lt;td&gt;&lt;code&gt;Monday&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;HH&lt;/code&gt;&lt;/td&gt;&lt;td&gt;24-hour hour&lt;/td&gt;&lt;td&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;mm&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Minutes&lt;/td&gt;&lt;td&gt;&lt;code&gt;05&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;ss&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Seconds&lt;/td&gt;&lt;td&gt;&lt;code&gt;09&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;Z&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Numeric zone&lt;/td&gt;&lt;td&gt;&lt;code&gt;+0500&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;zzz&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Short zone name&lt;/td&gt;&lt;td&gt;&lt;code&gt;EST&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</content>
  </entry>
  <entry>
    <title>Control flow</title>
    <link href="https://edadma.github.io/squiggly/syntax/control-flow/"/>
    <id>https://edadma.github.io/squiggly/syntax/control-flow/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>if / for / with / match — the block forms.</summary>
    <content type="html">&lt;p&gt;Squiggly’s block-form actions wrap a chunk of template content with conditional, iterative, or scoping logic.&lt;/p&gt;
&lt;h2 id=&quot;if-elif-else&quot;&gt;&lt;code&gt;if&lt;/code&gt; / &lt;code&gt;elif&lt;/code&gt; / &lt;code&gt;else&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;draft&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;badge&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Draft&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; elif &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;scheduled&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;badge&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Scheduled&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;badge&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Live&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;elif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; are optional. Truthiness rules are the same as in expressions — see &lt;a href=&quot;/squiggly/squiggly/syntax/expressions/#truthiness&quot;&gt;Expressions&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;for&quot;&gt;&lt;code&gt;for&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Two forms — value-only and key-value:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; p &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;pages&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; p&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; k&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt; v &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;frontmatter&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;dt&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; k &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;dt&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; v &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The iteration variable &lt;code&gt;p&lt;/code&gt; is bound inside the block; it’s not visible after &lt;code&gt;{{ end }}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;for&lt;/code&gt; works on lists and maps. Iterating a string treats it as a list of code-point characters.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;else&lt;/code&gt; works on &lt;code&gt;for&lt;/code&gt;: it runs when the iterable is empty.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; p &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;pages&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  …
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  No pages yet.
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;with&quot;&gt;&lt;code&gt;with&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;with&lt;/code&gt; evaluates an expression once and binds it as the current data context for the block. Inside the block, the leading &lt;code&gt;.&lt;/code&gt; refers to whatever you passed in.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;author&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the bound value is falsy, the block doesn’t render at all (and the optional &lt;code&gt;else&lt;/code&gt; runs):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;editor&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  Edited by &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;.
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  No editor.
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;match&quot;&gt;&lt;code&gt;match&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Pattern-match an expression against several literal values:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;status&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;draft&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;    &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;warn&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Draft&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;live&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;     &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Live&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;archived&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;muted&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Archived&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;            &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Unknown&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;else&lt;/code&gt; branch is optional but recommended — it catches unexpected values.&lt;/p&gt;
&lt;h2 id=&quot;variable-assignment&quot;&gt;Variable assignment&lt;/h2&gt;
&lt;p&gt;Inside any block, you can introduce a local with &lt;code&gt;:=&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; words &lt;span class=&quot;hl-punctuation&quot;&gt;:&lt;/span&gt;= split &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; wordCount &lt;span class=&quot;hl-punctuation&quot;&gt;:&lt;/span&gt;= len words &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;

This page has &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; wordCount &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt; words.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variable is scoped to the enclosing block.&lt;/p&gt;
&lt;h2 id=&quot;nesting&quot;&gt;Nesting&lt;/h2&gt;
&lt;p&gt;All four block forms nest freely:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; p &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;pages&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; p&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;draft&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
    &lt;span class=&quot;hl-comment&quot;&gt;{{ /* skip drafts */ }}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
    &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;article&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; p&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;article&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Comments</title>
    <link href="https://edadma.github.io/squiggly/syntax/comments/"/>
    <id>https://edadma.github.io/squiggly/syntax/comments/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>How to leave notes for future-you without affecting the rendered output.</summary>
    <content type="html">&lt;p&gt;Squiggly recognizes a single comment form, started inside an action with &lt;code&gt;//&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-comment&quot;&gt;// This won&apos;t appear in the output. }}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Everything from &lt;code&gt;//&lt;/code&gt; to the closing &lt;code&gt;}}&lt;/code&gt; is dropped at parse time. Useful for marking why a partial is being called or why a block is empty:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;sidebar&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-comment&quot;&gt;// sidebar is intentionally rendered before the main column so its&lt;/span&gt;
   &lt;span class=&quot;hl-comment&quot;&gt;// search input gets keyboard focus first. }}&lt;/span&gt;
{{ &lt;span class=&quot;hl-keyword&quot;&gt;block&lt;/span&gt; main &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt; … &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is no &lt;code&gt;/* … */&lt;/code&gt; style. If you want a multi-line comment, use multiple single-line ones, or wrap in &lt;code&gt;{{ if false }} … {{ end }}&lt;/code&gt; (the cost is the parser still walks the unused branch — fine for prose, expensive only if you nest very large templates).&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Collections</title>
    <link href="https://edadma.github.io/squiggly/builtins/collections/"/>
    <id>https://edadma.github.io/squiggly/builtins/collections/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>Operating on lists and maps — head, tail, append, distinct, sort.</summary>
    <content type="html">&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Arity&lt;/th&gt;&lt;th&gt;What&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;len&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Length of a list / map / string&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;isEmpty&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;True iff the collection has zero items&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;nonEmpty&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;True iff the collection has at least one item&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;head&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;First element of a list&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tail&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;All but the first&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;first&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Alias for &lt;code&gt;head&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;last&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Last element&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;reverse&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Reversed copy&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;sort&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Sorted copy (natural ordering on the elements)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;distinct&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Drop duplicates, preserving original order&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;compact&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Drop &lt;code&gt;null&lt;/code&gt; and the empty-tuple &lt;code&gt;()&lt;/code&gt; from a list&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;append&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;append elem list&lt;/code&gt; — append to the right&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;prepend&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code&gt;prepend elem list&lt;/code&gt; — prepend to the left&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; head &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;                          first positional arg
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; tail &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; join &lt;span class=&quot;hl-string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;               drop first, rejoin

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;for&lt;/span&gt; n &lt;span class=&quot;hl-keyword&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;nums&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; distinct &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; sort &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;      unique then sorted
  &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; n &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;items&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; nonEmpty &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;…&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        guard against empty list

&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;tags&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; append &lt;span class=&quot;hl-string&quot;&gt;&apos;featured&apos;&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;|&lt;/span&gt; join &lt;span class=&quot;hl-string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;  add a tag, render&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;maps&quot;&gt;Maps&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;for k, v &amp;lt;- m&lt;/code&gt; iterates a map. Many of the list builtins above work on maps too — &lt;code&gt;len m&lt;/code&gt; returns the entry count, &lt;code&gt;isEmpty m&lt;/code&gt; checks for an empty map.&lt;/p&gt;
&lt;p&gt;To pluck a value by key, use &lt;code&gt;[…]&lt;/code&gt; indexing in expressions:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;&apos;baseURL&apos;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;frontmatter.tags&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;        // dot syntax works for string keys&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Blocks and partials</title>
    <link href="https://edadma.github.io/squiggly/syntax/blocks-and-partials/"/>
    <id>https://edadma.github.io/squiggly/syntax/blocks-and-partials/</id>
    <updated>2026-05-10T23:04:32.478538713Z</updated>
    <summary>define / block / partial — composing templates from pieces.</summary>
    <content type="html">&lt;p&gt;Two ways to share template content across multiple files, with quite different shapes.&lt;/p&gt;
&lt;h2 id=&quot;partials&quot;&gt;Partials&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;partial&lt;/strong&gt; is a template loaded by name from a &lt;code&gt;TemplateLoader&lt;/code&gt;. The renderer looks up the name through the loader’s &lt;code&gt;String =&amp;gt; Option[TemplateAST]&lt;/code&gt; callback, then renders the result with whatever data context you pass in.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;topbar&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;page-toc&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;hl-string&quot;&gt;&apos;footer&apos;&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-keyword&quot;&gt;with&lt;/span&gt; title=&lt;span class=&quot;hl-string&quot;&gt;&apos;Hello&apos;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first argument is a string literal — the name. The second is the data context to render with. Use &lt;code&gt;.&lt;/code&gt; to pass the current context unchanged.&lt;/p&gt;
&lt;p&gt;Partials are &lt;strong&gt;dynamic&lt;/strong&gt; — looked up at render time, useful when the partial isn’t known until you’ve parsed the templates.&lt;/p&gt;
&lt;p&gt;Wire up partials by passing a loader to the renderer:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; partials&lt;span class=&quot;hl-punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateLoader&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; name &lt;span class=&quot;hl-keyword&quot;&gt;=&amp;gt;&lt;/span&gt; myPartialMap&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; renderer &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateRenderer&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;partials &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; partials&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;define-block&quot;&gt;Define / block&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;define&lt;/code&gt; and &lt;code&gt;block&lt;/code&gt; work together to support a “fill-in-the-blanks” layout pattern. A &lt;em&gt;parent&lt;/em&gt; template declares slots with &lt;code&gt;{{ block name . }} … {{ end }}&lt;/code&gt; (with optional default content). A &lt;em&gt;child&lt;/em&gt; template populates those slots with &lt;code&gt;{{ define name }} … {{ end }}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The renderer’s &lt;code&gt;blocks&lt;/code&gt; field is a &lt;code&gt;mutable.HashMap[String, TemplateAST]&lt;/code&gt; carrying the bindings; render the child first to populate it, then render the parent.&lt;/p&gt;
&lt;h3 id=&quot;a-two-pass-example&quot;&gt;A two-pass example&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;baseof.html&lt;/code&gt; (the parent layout):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;hl-keyword&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;hl-function&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.title&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;block&lt;/span&gt; content &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
      &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;Default content&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;page.html&lt;/code&gt; (the child):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;define&lt;/span&gt; content &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;article&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;page.title&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-variable&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;article&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To render the page:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-scala&quot;&gt;&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; parent &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; parser&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;parse&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;baseof&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; child  &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; parser&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;parse&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;page&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl-keyword&quot;&gt;val&lt;/span&gt; renderer &lt;span class=&quot;hl-keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hl-type&quot;&gt;TemplateRenderer&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;()&lt;/span&gt;

renderer&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;render&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt; child&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;hl-comment&quot;&gt;// first pass: populates `define` blocks&lt;/span&gt;
renderer&lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt;render&lt;span class=&quot;hl-punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;hl-punctuation&quot;&gt;,&lt;/span&gt; parent&lt;span class=&quot;hl-punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;hl-comment&quot;&gt;// second pass: `block content` finds the&lt;/span&gt;
                               &lt;span class=&quot;hl-comment&quot;&gt;// populated definition and substitutes&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first render writes nothing visible — its purpose is the &lt;code&gt;define&lt;/code&gt; side effect.&lt;/p&gt;
&lt;p&gt;This is the pattern juicer uses for its &lt;code&gt;_default/baseof.html&lt;/code&gt; + &lt;code&gt;_default/file.html&lt;/code&gt; / &lt;code&gt;_default/folder.html&lt;/code&gt; layout combinations.&lt;/p&gt;
&lt;h3 id=&quot;default-content&quot;&gt;Default content&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;{{ block name . }} … {{ end }}&lt;/code&gt; renders its inner content if no &lt;code&gt;define&lt;/code&gt; populated the block.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-squiggly&quot;&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;block&lt;/span&gt; sidebar &lt;span class=&quot;hl-punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;
  &lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;No sidebar configured.&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-function&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-punctuation&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl-punctuation&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;hl-keyword&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;hl-punctuation&quot;&gt;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If &lt;code&gt;sidebar&lt;/code&gt; was never defined, the default is what gets rendered.&lt;/p&gt;
&lt;h2 id=&quot;when-to-pick-which&quot;&gt;When to pick which&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Situation&lt;/th&gt;&lt;th&gt;Use&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Reusable fragment with its own data context (header, card, badge)&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Partial&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;“Outer shell” + variable inner content per page kind&lt;/td&gt;&lt;td&gt;&lt;strong&gt;define / block&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Many similar pages with different bodies&lt;/td&gt;&lt;td&gt;&lt;strong&gt;define / block&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Optional decorations chosen at render time&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Partial&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Both compose well — your &lt;code&gt;baseof&lt;/code&gt; block can &lt;code&gt;{{ partial &apos;topbar&apos; . }}&lt;/code&gt; inside it.&lt;/p&gt;</content>
  </entry>
</feed>
