gscan
gscan copied to clipboard
Detect misusage of handlebars
Steps to reproduce:
- Add e.g.
{{#if img_url feature_image}}in your post.hbs - Navigate to any post
TypeError: [post.hbs] Cannot read property 'includeZero' of undefined
at Object.<anonymous> (/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/helpers/if.js:16:22)
The if helper is an inbuilt helper of Handlebars. People sometimes misuse this helper. Would be great to detect that in gscan.
- [x] add a warning in our instructions and double check docs
- [ ] add detection in gscan
As far as I know, the only reason we're seeing this happen is because the output from gscan about changing instances of image tell them to do a straight swap to img_url feature_image.
I've never seen people do this before 1.0 - and all of them were following instructions from gscan.
Therefore, before we add an extra check, I think the first task is to fix the instructions?
As far as I know, the only reason we're seeing this happen is because the output from gscan about changing instances of image tell them to do a straight swap to img_url feature_image.
100%.
I'll added subtasks to the issue.
Another case is if you are using the {{pagination}} helper wrong.
e.g. if the helper is not used within a post context object. Then Ghost would complain and throw pagination data is not an object or is a function error. This error message should be improved. Docs should be improved as well.