Expression Escape Content in Reactive Web

Is there an alternative to 'Escape Content' on an expression in a Reactive Web application? If not, are there plans to add it? 

Yes, I know I can (and should) use widgets to build the UI, but in certain cases I may want/need to build an HTML expression.

Hello Joseph, 

I didn't took a deep look into reactive, but as ut and mobile uses the same programming model, I would say you can use the HTML widget in the screen. 

It exists in mobile and should exists in Reactive Web apps as well... 

Cheers 

Solution

Hi Joseph,

You will need to use a JavaScript node to set the innerHTML of some widget.

Cheers,

Tiago Simões

Solution

Hello Tiago,

Can't use the HTML element?

OK, I see.

With the HTML element, you will need to build every part of the HTML piece of code using the canvas (with potentially other HTML elements), while using JavaScript you can just "write" your HTML and inject it...

I would like to have the "unescaped" expression... Neither available way is good...

Cheers

Hi Eduardo,

You can encapsulate the JavaScript above in a block (as shown in the screenshot) and use it as a widget. 

Cheers,

Tiago Simões 

PS: be sure to sanitize the HTML content, so users are not allowed to inject arbitrary JS in your app. 

2 more things:

- the HTML element is static so that Service Studio knows how to render it, and is useful to create UI components.

- it may go without saying, but it’s a good practice to centralize generalist blocks with custom JavaScript and HTML in libraries, so it’s easier to maintain. The less JS you have on your app, the easier it will be to change it in the future. 

Tiago Simões wrote:

You can encapsulate the JavaScript above in a block (as shown in the screenshot) and use it as a widget. 

If you meant to use more than one time, this will enable you to create a reusable piece of code.
I was thinking more about a "one-time" injection. The old "non-escaped" expressions were more practical :)

But after a little thought, I understand that injecting HTML is not a good practice (for obvious reasons) and so, it should be used only rarely. So, yes, I accept your solution ;D

Thank you!

Cheers!


Thanks guys. Yes, I was aware of the HTML widget, but as you indicated, I would have to chain them together so it won't work for my purpose. The javascript option worked perfectly, though (I marked it as the solution).