Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper value not resolved #1759

Open
stevemk14ebr opened this issue Jun 15, 2021 · 1 comment
Open

Helper value not resolved #1759

stevemk14ebr opened this issue Jun 15, 2021 · 1 comment

Comments

@stevemk14ebr
Copy link

stevemk14ebr commented Jun 15, 2021

Hello, I'm having an issue with custom helpers. My helper is getting the name of the key unresolved, instead of the value as expected when using a certain key style.

My helper is simple:

HandleBars.registerHelper('truncate', (context, arg1) => {
    if (!context) {
        return `INVALID_HANDLEBARS_PLACEHOLDER`;
    }
    let val = context.substring(0, arg1);
    return new HandleBars.SafeString(val);
});

I use this like this (and it works):

sample with MD5 hash {{{md5}}} ({{{truncate md5 6}}}...)

This however fails and just gives me the key (File.md5). So the truncation of the value fails and returns File.m instead of the shortened hash.

{{{"Characteristics.original filename"}}} ({{{truncate "File.md5" 6}}})

My json for the second is valid, and does render just fine without the truncate helper being used. I'm also not sure why quotes are required but I had to do this to get it to work:
image

Renders as:
image

@stevemk14ebr
Copy link
Author

The issue is with the json path implementation. It's trying to access the fields as json path but fails since they are not nested json but rather keys with json path style, it should probably try the key access first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants