Search code examples
handlebars.jspalantir-foundryfoundry-slatepalantir-for-ibm-cloudpak-for-data

Is it possible to define a handlebars inside another handlebars in Slate within Palantir-Foundry?


I want to draw a chart in foundry slate. I want to define x axis and y axis as follows:

X = "{{fchart.{{w_widget.selectedValue}}}}"

Y = "{{fchart.summation}}" 

I need to dynamically get the value of w_widget.selectedValue by defining it within another handlebars.

But this is throwing error?


Solution

  • You cannot nest handlebars. Given the limited information you are giving, I'm going to have to do some assumptions here. It seems to be trying to dynamically choose field that contains the X axis within an object containing data for your chart?

    Try to place this inside a slate function and do:

    x = {{fchart}}["{{w_widget.selectedValue}}"]
    

    What is happening here is that first you pull out the object, returned in your fchart function. Then you use the string inside the widget to access the content. Which should be the same as doing:

    let chart_obj = {{fchart}};
    let property_name = {{w_widget.selectedValue}};
    
    let x = chart_obj[property_name]