HTML flow variables in Text View

I am having trouble getting HTML contained in a flow variable to render properly in the new Text View node. If I select the option to use a single flow variable for the whole output, the content renders as formatted HTML. But if I embed the variables by using the $$[“variable-name”] syntax, I only see the raw, unformatted HTML.

I need to use the latter approach because I want to combine multiple HTML snippets into a single view. Is this supposed to be possible? Or do I need to assemble the pieces manually into a single HTML string and load it in the Text View as a single variable?

Hi @AngusVeitch , it would be easier to guide you if we could see an example of what you are doing, but this worked for me
flow variables in html - text view.knwf (21.8 KB)

In this example, I use a component to make it easier to write the html text for demo purposes, but there is nothing special and it is just creating a string.

If this doesn’t give you the pointers you need, and you still cannot get yours working, then please upload a simple example.

btw I wasn’t quite sure what you meant about using a single variable versus multiple variables. As far as I can see, you’d ultimately need a single variable to pass to the Text View config as I’ve done here. Are you anticipating passing multiple variables other than how I’ve done it?

2 Likes

Hi @takbb , what you have done here is is what I described as passing a single variable. What I want to do instead is write my own content into the config of the Text View, in which I insert flow variables amongst the free text, just like what is possible in the old Text Output Widget. As per the Text View documentation, I can do this using a special syntax for the flow variables.


As you can see, the variables are being rendered as plain text rather than HTML.

In the Text Output Widget, I can enter:
$${Shtml_A}$$
Some free text
$${Shtml_B}$$
$${Splain-text}$$

…and as long as I select the HTML option, it renders as formatted text without the tags.

So it looks like I need to compile the whole HTML output as a variable first if I want the Text View to render it that way. Perhaps an HTML option will be added to the Text View in the future, similar to the Text Output widget?

1 Like

Hi @AngusVeitch

Ah ok, I better understand what you are saying now that I can see the screenshot. When you said ‘embed the variables by using the $$[“variable-name”] syntax’ I thought you meant embedding them using that format within the single flow variable. I now realise you were talking about entering them on the Rich Text Content form.

Unfortunately, I think that entering text directly within config is designed to be content only, rather than formatting, since the formatting on this option is performed by way of the toolbar controls, so any text contained within the flow variables at that point will be treated as text literals to be output rather than html tags.

The documentation for the Text View does say “Note, this node is currently under development. Future versions of the node might have improved or changed functionality.” so perhaps adding the ability to specify “treat a section of text (or all text) as html” might be something to add in the “feedback & ideas” section of the forum?

1 Like

One possible way forward is to perform the similar string replacements on behalf of the Text View node.

Here i have created some variables,

I have then used the CSS Editor, not to edit CSS but to provide a convenient means for entering the text data that would otherwise have been written in the Text View node:

I then have a component written in java that does (subject to testing!) the replacements of the flow variable strings, so


becomes

This text is then supplied directly as a single flow variable to Text View which displays it as this:
image

I had to cheat slightly with the bold option, since the <b> tag didn’t seem to have much of an effect (if any). So I used <h6> instead.

flow variables in html - text view 2.knwf (93.2 KB)

3 Likes

Thanks for the example. All of this makes me think that the Text Output Widget has been retired too soon! Hopefully the Text View will catch up before too long.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.