handlebars-lang / handlebars-lang/handlebars.js
Indented `{{> @partial-block }}` cannot handle a SafeString.
- Dominant language
- JavaScript
- Stars
- 18.7k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
* [x] This is NOT a security issues!! If it is, please file a report at https://www.npmjs.com/advisories/report?package=handlebars**
# Bug description
Indented `{{> @partial-block }}` cannot handle a SafeString. I run into this when I have a block helper that returns an instance of `SafeString` as the only content in a partial block. Easiest to checkout the included example link.
# Example link
https://handlebarsjs.com/playground.html#format=1¤tExample=%7B%22template%22%3A%22%7B%7B%23%3Emy_partial%7D%7D%7B%7B%23safe%7D%7D%7B%7B%2Fsafe%7D%7D%7B%7B%2Fmy_partial%7D%7D%5Cn%22%2C%22partials%22%3A%5B%7B%22name%22%3A%22my_partial%22%2C%22content%22%3A%22%20%5Cn%20%20%20%7B%7B%3E%20%40partial-block%20%7D%7D%22%7D%5D%2C%22input%22%3A%22%7B%7D%22%2C%22output%22%3A%22%20%5Cn%20%20%20%7B%7Btest%7D%7D%5Cn%22%2C%22preparationScript%22%3A%22Handlebars.registerHelper('safe'%2C%20function%20()%20%7B%5Cn%20%20%20%20return%20new%20Handlebars.SafeString(%5C%22%7B%7Btest%7D%7D%5C%22)%3B%5Cn%7D)%5Cn%22%2C%22handlebarsVersion%22%3A%224.7.6%22%7D
# Expected outcome
Renders an indented, safe string.
# Actual outcome
Throws a `.split is not a function` error.
Contributor guide
Research direction
Start with the linked Handlebars playground example and reproduce the `.split is not a function` failure for an indented `{{> @partial-block }}` containing a SafeString. Trace partial-block indentation and SafeString handling from that entry point, then verify that the example renders the expected indented safe string without the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- handlebars, javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100