Displaying HTML with Jelly in a UI page

jdurden
Kilo Explorer

So, I went into this project thinking this was going to be pretty straight forward. And, maybe it is. But what I thought should work intuitively isn't working as I anticipated and the information I'm finding online isn't working.

What I'm trying to do is display some HTML (on a UI Page) which is stored in a variable. Example...



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var test = "<b>this is bold</b>";
</g:evaluate>

${test}
</j:jelly>


In case it's not clear, the desired outcome is to have a simple bold text "this is bold" display on the UI Page when visited. However, when you visit the page it looks like:

<b>this is bold</b>


Clearly the HTML is being encoded at some point in this whole thing and, despite searching forums and Google, I'm unsure how to fix it. Any ideas?


Thanks in advance!

25 REPLIES 25

I am encountering the same issue in Helsinki.



Created a Widget displaying my UI page. Each of the methods below work to an extent, but whenever the refresh button on the widget is used, it shows the raw markup instead. Refreshing the whole dashboard or page resolves it, but does anyone know how to get the widget to refresh it properly?



I've used both of these methods, but get the same result:


<g2:no_escape>$[HTML:annAdv.u_html]</g2:no_escape>


<g2:no_escape>$[annAdv.u_html.getDisplayValue()]</g2:no_escape>


Hi Simon,



For me below code is working for Helsinki.



<g:no_escape>${HTML:current.text}</g:no_escape>



BR,


/Suraj


I works for me as well, but only initially. I am using the code in a dashboard widget, and when the widget refreshes, it shows the raw code. Here are some screenshots to show what I am talking about:



Displayed, are two test entries to my widget. everything looks fine. There is even a hyperlink at the bottom of the 2nd one.






However, when I use the refresh button in the top right corner of the widget, it looks like this:




Hey Goran,



I tried this solution but the HTML tags are still showing.   Any ideas how to fix this?



Screen Shot 2016-11-03 at 9.59.16 AM.png



Thanks,



Josh


Manville
Mega Guru

In case anyone has this issue, g2:no_escape does not work on catalog items. use g:no_escape instead