handlebars.js icon indicating copy to clipboard operation
handlebars.js copied to clipboard

Indented `{{> @partial-block }}` cannot handle a SafeString.

Open jbsulli opened this issue 4 years ago • 4 comments

  • [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&currentExample=%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.

jbsulli avatar Jun 13 '20 18:06 jbsulli