Skip to content

feat(executor): add direct block execution for conditional blocks - #25

Merged
atinseau merged 1 commit into
masterfrom
feature/direct-block-execution
Mar 17, 2026
Merged

atinseau merged 1 commit into
masterfrom
feature/direct-block-execution

Conversation

@atinseau

Copy link
Copy Markdown
Owner

Summary

  • Add tryDirectBlockExecution() to evaluate #if/#unless blocks directly without Handlebars rendering
  • Preserves non-string return types (e.g. arrays from map) when the selected branch resolves to a non-primitive value
  • Falls back to existing Handlebars rendering path when direct execution is not applicable

Why

Previously, wrapping a map call inside {{#if condition}}...{{/if}} would cause Handlebars to stringify the array result. Direct block execution evaluates the condition and delegates to the existing type-preserving execution paths, so callers receive the raw array (or other typed value) instead of a string.

Test plan

  • bun test tests/direct-block-execution.spec.ts — all 557-line suite passes
  • Verify #if with truthy/falsy conditions returns correct branch value
  • Verify #unless inverts condition correctly
  • Verify fallback to Handlebars when branch is a plain string mustache
  • Verify nested conditionals work correctly

@atinseau
atinseau merged commit 0074e23 into master Mar 17, 2026
2 checks passed
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