Skip to content

Add truncate, pluralize, list and rounding functions, and + for text - #10

Merged
mierau merged 1 commit into
mainfrom
claude/project-thread-cj3hxv
Oct 10, 2026
Merged

mierau merged 1 commit into
mainfrom
claude/project-thread-cj3hxv

Conversation

@mierau

@mierau mierau commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Before: common jobs needed custom functions or if blocks. Truncating a bio meant registering a function, "1 comment / 3 comments" took a three-branch if, lists couldn't be sorted or filtered in a template, and "Hi " + name gave nothing because + only added numbers.

After:

{% person.bio | truncate(40) %}
{% post.comments.@count | pluralize("comment") %}
{% people | where("admin") | sort("name") | first %}
{% price | round(2) %}
{% "Hi " + person.name + "!" %}

New functions:

  • truncate(n, ending) shortens text to at most n characters, including the ending ("…" by default).
  • pluralize(singular, plural) gives the count with the right word. plural defaults to the singular plus "s".
  • sort / sort(key) is stable and puts nil last. where(key, value) / where(key) filters a list, and unique removes duplicates.
  • first, last and count are now functions too, so they chain in a pipe. .first without parentheses is still a key lookup.
  • round(places), floor, ceil and abs.

How: + joins text when either side is text that isn't a number, and nil joins as nothing. Two numeric strings still add as numbers, so "41" + 1 stays 42.


Generated by Claude Code

@mierau mierau self-assigned this Oct 10, 2026
@mierau
mierau force-pushed the claude/project-thread-cj3hxv branch from 7185510 to cd2ce25 Compare October 10, 2026 12:53
…th +.

New built-in functions: truncate, pluralize, sort, where, unique, first,
last, count, round, floor, ceil and abs. + joins text when either side is
text that isn't a number, so "Hi " + name works; numeric strings still add.
@mierau
mierau force-pushed the claude/project-thread-cj3hxv branch from cd2ce25 to e6073b5 Compare October 10, 2026 13:02
@mierau
mierau merged commit c13296c into main Oct 10, 2026
2 checks passed
@mierau
mierau deleted the claude/project-thread-cj3hxv branch October 10, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant