From 96113f7df105b241fcdbdf0a8dc7e07afa130de2 Mon Sep 17 00:00:00 2001 From: dupontbertrand Date: Fri, 3 Apr 2026 02:00:53 +0200 Subject: [PATCH 1/2] fix: improve error messages for invalid template tags in HTML start tags Replace the generic "Reactive HTML attributes must either have a constant name..." message with specific, actionable errors for each case: - {{#if}}/{{#unless}} in start tag: suggests attribute="{{helper}}" pattern - {{{triple-stache}}} in start tag: explains raw HTML issue - {{> inclusion}} in start tag: mentions it's not allowed - Custom block helpers: clear rejection message --- .../spacebars-compiler/spacebars_tests.js | 25 +++++++++++++-- packages/spacebars-compiler/templatetag.js | 31 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/packages/spacebars-compiler/spacebars_tests.js b/packages/spacebars-compiler/spacebars_tests.js index 530a47bc3..390f1779d 100644 --- a/packages/spacebars-compiler/spacebars_tests.js +++ b/packages/spacebars-compiler/spacebars_tests.js @@ -246,12 +246,29 @@ Tinytest.add("spacebars-compiler - parse", function (test) { test.equal(BlazeTools.toJS(SpacebarsCompiler.parse('{{#foo}}x{{else bar}}{{#baz}}z{{/baz}}{{/foo}}')), 'SpacebarsCompiler.TemplateTag({type: "BLOCKOPEN", path: ["foo"], content: "x", elseContent: SpacebarsCompiler.TemplateTag({type: "BLOCKOPEN", path: ["bar"], content: SpacebarsCompiler.TemplateTag({type: "BLOCKOPEN", path: ["baz"], content: "z"})})})'); + // Triple-stache in start tag — should mention raw HTML test.throws(function () { SpacebarsCompiler.parse(''); - }); + }, /Triple-stache.*raw HTML/); + + // Block helper in start tag — should suggest attribute="{{helper}}" pattern test.throws(function () { SpacebarsCompiler.parse(''); - }); + }, /not allowed in an HTML start tag/); + + // Common real-world patterns that trigger this error + test.throws(function () { + SpacebarsCompiler.parse(''); + }, /Bad syntax.*Good syntax/); + test.throws(function () { + SpacebarsCompiler.parse('