Could not find handlebars helper

Hi,

I have created a custom handlebars helper.

The helper (javascript file) is placed under:

src/assets/hbs/

The partial contents of that helper file are:

Handlebars.registerHelper(‘ifStartsWithThisOrThat’, function(inputValue, thisValue, thatValue, options) {
// super secret implementation :slight_smile:
});

The instance tab provider class is importing the renderer class:

import com.morpheusdata.views.HandlebarsRenderer

The handlebars/view (.hbs) has the script element:

script src=“{{asset “/hbs/handlebarsHelpers.js”}}”

But it looks like that the plugin is not able to find that helper.
The error message is:

JAVA.LANG.ILLEGALARGUMENTEXCEPTION: COULD NOT FIND HELPER: ‘IFSTARTSWITHTHISORTHAT’

(The uppercase of the error message is because it is within the span element with class=“stat-label”. The helper is registered with exactly the same name.)

What did I miss? :confused:

Thanks in advance! :slight_smile:

Tried to override the getRenderer method in the provider class. Still not working.

private HandlebarsRenderer renderer;

@Override
Renderer<?> getRenderer() {
if(renderer == null) {
renderer = new HandlebarsRenderer(“renderer”, getPlugin().getClassLoader());
renderer.registerAssetHelper(getPlugin().getName());
}
return renderer;
}

Looks like there is no need to override this method.
The asset helper was still working/registered.

Added the paragraph element in our HBS file:

{{asset “/hbs/handlebarsHelpers.js”}}

The result/output was:

/assets/plugin/ais-instance-vulnerabilities-tab-plugin/hbs/handlebarsHelpers.js

However, we are not able to see this script when we inspect the sources (developer tools).

Also tried to override the following method.

@Override
ContentSecurityPolicy getContentSecurityPolicy() {
return new ContentSecurityPolicy()
}

Still not working.