Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

HTML widget

HTML widget

New Contributor

I'm using Hue Search to build a dashboard.

 

Does anyone have an example of javascript being used to conditionally return a value?

 

For example, in my html tab I use something like {{value}} to refer to a var defined in an if/else statement in the CSS/JS tab.

8 REPLIES 8

Re: HTML widget

Cloudera Employee

hi,

we use Mustache.js to render the items (or docs) returned from a search, so the variable you can reference from the editor are just the fields of the result doc and not JS variables you define.

We've seen something similar around where you define for instance a hidden column with the value you want to test and use jQuery to conditionally change what you want to change.

Re: HTML widget

New Contributor

Is there any way to add helper functions from the JS/css page ? Was trying to use the {{if value}} {{/if}} but that function does not seem to be available. Is there an easy way to add these functions ?

Re: HTML widget

Re: HTML widget

New Contributor

Thanks I have been googling and looking at the docs unfortunatly the IF and other functionality is not working. I am not sure if this is a shortcoming of the hue UI. Here is the exact code and not sudo code

We are using hue 3.8, it appears by looking at the source code that hue is referencing a mustache version 0.7.2 ( a little behind the current 2.1.2) so it might be that if helper is not supoorted ?

Because {{#if val}}{{val}}{{/if}} does not work.

I also tried doing the undefined or empty type function

this {{resultType}} is rendered to 'testType'

but this

{{#resultType}}{{resultType}}{{/resultType}} renders nothing, although according to the docs it should.

 

Any idea whats going on here ? Should we modfiy the templates directly instead of using hues UI ?

 

Highlighted

Re: HTML widget

New Contributor
It's too bad that " {{#resultType}}{{resultType}}{{/resultType}} " is not working... how can we render multivalued fields ?

Re: HTML widget

Enrico can explain why it is not directly possible but at least doable with
this workaround: http://gethue.com/enhance-search-results/

Romain

Re: HTML widget

New Contributor
Many thanks! I don't understand how I missed that!

Any plans to add that in the documentation? At first sight, the html+js+css seems powerful, but it's not obvious to know how to hack the rendering in javascript.

Re: HTML widget

We have a big Hue 4 revamping coming out next year. It will have a new
documentation section instead of just using the blog posts as doc.

Will be cleaner :)

Romain

Don't have an account?
Coming from Hortonworks? Activate your account here