johnknoop / vscode-handlebars-preview

Preview Handlebars templates in VS Code
MIT License
16 stars 10 forks source link

Support for helpers #12

Closed mateusgrb closed 3 years ago

mateusgrb commented 5 years ago

I have a couple helpers, registered like this:

  Handlebars.registerHelper('ifIsNotEqual', function(v1, v2, options) {
    if (v1 === v2) {
      return options.inverse(this);
    }

    return options.fn(this);
  });

When I try to open the extension for a template, I get: Error rendering handlebars template: {"message":"Missing helper: \"ifIsNotEqual\"","name":"Error"}

johnknoop commented 5 years ago

Helpers aren't supported (yet). Only data. The plugin will only look for a json file with the matching name, but will disregard js files.

This is something we should probably add, but I have limited time this week. I'll add a "help wanted" label to this issue in case someone else (you maybe?) wants to implement it and create a PR. Otherwise I will have a look at it at some point.