Backport commit 5614c5ef9f from daaain/Handlebars