Handlebars Templating: Handling Generator Errors

In this article we’ll look at one benefit of using the handlebars tool, and one or two idiosyncrasies. After the last post, it is nice to have a fairly short and straightforward article.

The Output File name

In the form for starting the program, there is a place to enter an output file name.

This is meant to be a html file, but it will accept any text. So be careful to enter a file ending with .html, like template.html.

When you click Generate, that file will be created, even if it has a nonsensical file name. Luckily, once a html file exists, it will automatically appear here every time to you change the folder, so you only need to be careful of this once.

The Generate Button

I haven’t seen this glitch in a while, so it might not exist in recent versions of the program: bear that in mind. I’ll talk as if it still exists.

Sometimes the Generate button is greyed out., for example if the output file name is empty. Make sure you have a valid Output File Name, and uf it is still greyed out, change the Output File Name – remove one character or add one character. You can change it back afterwards.

Note that when you click the Generate button, it’ll create the file in Output File name, and it will overwrite any file that exists with that name without asking for permission. Usually that’s exactly what you want to happen, but if it isn’t, remember you can change the output file name easily.

Handlebars Errors

When you click the generate button, and an invalid handlebars file would be created, an error will be displayed instead. No file will be created, and you’ll be given an error like this:

I normally include most of the text – the important part is the line number. It usually means a handlebars specific command isn’t correct, and it’s usually pretty easy to fix.

Important: this only checks for handlebars errors. If your html or javascript contains an error, this won’t detect that. It can be very handy to know there’s a problem with your handlebars code.

Series Navigation<< Handlebars Templating: Nesting in All Its FormsHandlebars Templating: Helpers >>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.