handlebars-lang / handlebars-lang/handlebars.js

Error when using `~` within `{{{...}}}`

Open
#2,039 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs-needed
Dominant language
JavaScript
Stars
18.7k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Example 1:

Code:

const Handlebars = require('handlebars');
var tpl = Handlebars.compile("123\n{{{~myvar}}}\n123");
tpl({myvar: '<myvar>'});

Result:

Uncaught Error: Parse error on line 2:
123{{{~myvar}}}123
------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'
Example 2:

Code:

const Handlebars = require('handlebars');
var tpl = Handlebars.compile("123\n{{{myvar~}}}\n123");
tpl({myvar: '<myvar>'});

Result:

Uncaught Error: Parse error on line 2:
123{{{myvar~}}}123
-----------^
Expecting 'CLOSE_UNESCAPED', 'OPEN_SEXPR', 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'CLOSE'

Node.js: v21.6.2
handlebars: v4.7.8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing both examples with Node.js and Handlebars.compile, then trace the Handlebars parser entry point for triple-stash expressions containing ~. Done means both leading and trailing ~ forms parse and render the supplied value without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, javascript, node.js
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.