kwc
March 20, 2024, 4:06pm
1
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
});
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?
Thanks in advance!
kwc
March 21, 2024, 2:06pm
2
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;
}
kwc
March 21, 2024, 2:39pm
3
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).
kwc
March 26, 2024, 8:48am
4
Also tried to override the following method.
@Override
ContentSecurityPolicy getContentSecurityPolicy() {
return new ContentSecurityPolicy()
}
Still not working.