כיצד ליצור פונקציית עזר של Handlebars

Your code should work, but you’re using your helper

{{sample}}

in the template without passing it any arguments. Even if you’re testing to see if things work, pass it a test string like

{{sample "some string"}}

You need to do that because you’re using the helper in a raw hbr template. For testing purposes, the helper should work even if you don’t pass it anything in regular hbs templates.

If you’re creating a block-helper, then it needs to have # and you need to close it like so.

{{#sample}}

{{/sample}}

Adding ~ to your helper optionally trims whitespace between any HTML tags it returns. So

{{~#sample}}

{{/sample}}