Compile Handlebars templates with Grunt

During the refactoring of views in my Strava Desktop pet project, I decided to switch from manually rendered views to Handlebars templates.

I did a quick search of available Grunt plugins. There are plenty of them. The ‘official’ grunt-contrib-handlebars plugin got stuck with the Handlebars 3.0 version. Furthermore, I didn’t like the code it generated. It didn’t allow me to customize the template name (basically strip a prefix). I didn’t want to refer to my template as src/templates/stravaAuth.hbs – just stravaAuth.

Instead of going the complex way, I called the handlebars command using the grunt-run plugin. This is my configuration:

The moral of the story: you don’t always need a fancy plugin. Calling the tool directly is good enough.