gscan icon indicating copy to clipboard operation
gscan copied to clipboard

Detect misusage of handlebars

Open kirrg001 opened this issue 8 years ago • 2 comments

Steps to reproduce:

  1. Add e.g. {{#if img_url feature_image}} in your post.hbs
  2. 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

kirrg001 avatar Sep 11 '17 09:09 kirrg001

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?

ErisDS avatar Sep 11 '17 09:09 ErisDS

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.

kirrg001 avatar Nov 28 '17 12:11 kirrg001