Skip to content

Add array helpers, fix template errors, and tweak examples#167

Merged
alexwarren merged 13 commits intomainfrom
tweak-examples
Jan 27, 2026
Merged

Add array helpers, fix template errors, and tweak examples#167
alexwarren merged 13 commits intomainfrom
tweak-examples

Conversation

@alexwarren
Copy link
Contributor

Summary

  • Add array management helpers (append, prepend, pop, remove, contains, length) for the text processor
  • Fix set helper to unwrap SafeString values from subexpressions
  • Display template errors visibly instead of failing silently
  • Fix input validation within {{#animate}} blocks
  • Clarify array helper docs to use "attribute" parameter name consistently
  • Update coffeeshop and gameshow examples
  • Add runtime and plugin tests for new functionality

Test plan

  • Run npm test to verify all compiler and runtime tests pass
  • Test the coffeeshop and gameshow examples via CLI
  • Verify template errors are displayed visibly in the browser

🤖 Generated with Claude Code

alexwarren and others added 13 commits January 25, 2026 16:25
When using helpers like `random` as subexpressions with the `set` helper
(e.g., `{{set "x" (random (array "a" "b"))}}`), the value was being stored
as a Handlebars SafeString object instead of a plain string, causing
`[object Object]` output and broken conditionals.

The set helper now converts objects with toString() to strings before storing.

Also updates gameshow example to use this pattern for silent random selection,
and adds a test for the subexpression scenario.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… length)

Implements feature request from issue #166. These helpers allow managing
arrays stored in attributes - useful for tracking items, available options,
or game state like rounds that shouldn't repeat.

- append: Add element(s) to end of array
- prepend: Add element(s) to start of array
- pop: Remove and return first element
- remove: Remove first matching value
- contains: Check if array contains value
- length: Get number of elements

Also refactored set helper to use shared unwrapValue function, and updated
the gameshow example to use these helpers for non-repeating rounds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When Handlebars template compilation or execution fails, errors are now
displayed on screen in a styled error box with monospace font, instead of
silently failing with no output. Errors are also logged to the console.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename "listVar" to "attribute" to match other helpers, add note
explaining the parameter is an attribute name (string), not the array.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alexwarren alexwarren merged commit 07c76c8 into main Jan 27, 2026
5 checks passed
@alexwarren alexwarren deleted the tweak-examples branch January 27, 2026 18:29
@alexwarren alexwarren mentioned this pull request Jan 27, 2026
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