markjgsmith

Notes

05:12:00 +07:00 On a more positive note, I think I'm pretty close to getting the links on the everything page into their own little footer section on each article. I spent all day yesterday trying to find a bug in an EJS template. Absolute nightmare to track down because the stack trace gives no details of where the error occurs.

A bit of googling revealed it was likely related to missing EJS closing tags. I spent all day adjusting indentation of the template, splitting the template into multiple templates, bisecting the template, striping it down to a shell, then painstakingly adding blocks back one at a time, in order to find the bug.

Turns out I was looking for slightly the wrong thing. It wasn't a tag closing problem, it was a for loop problem. I had introduced 2 new for loops but somehow mistakenly typed the opening curly as a semi-colon.

for(var i = 0; i < blah; i++);

instead of

for(var i = 0; i < blah; i++) {

Note: in the real code both statements are wrapped in EJS opening and closing tags. I can't add those in this post because then the EJS renderer will mistakenly try to render the EJS in the example snippet, and error. Not sure how to escape that at this point, so just not including it. You'll have to use your imagination.

So anyway, visually very difficult to see the bug, especially because I was looking for problems with closing EJS tags, which is right next to it. The advice from the internet was quite literally hiding the actual problem. Somehow the bug was resulting in the same error as a missing closing tag. So that's fixed.

I've added a bunch of debug logging too, so hopefully at some point today I'll have the links displaying correctly. #

For enquiries about my consulting, development, training and writing services, aswell as sponsorship opportunities contact me directly via email. More details about me here.