Output multiline string with line breaks

Hi

I want show a multiline string with line breaks.

Something like this ($content is just an example, I got the multiline string from the eventlog):
$content = “ä” + [environment]::newline + “ö”
New-UDParagraph -Text $content #outputs “äö”
New-UDParagraph -content {$content} #error can not output ä,ö
New-UDParagraph -Text $content.replace([environment]::newline,"") #outputs “äö”

How can I do that?

Best regards,

Hi @xcabur,

NewLine in HTML is

<br>

IE: replace your new-line character with <br> in order to archieve this.
The content-param is a scriptblock, which needs to be invoked, and rendered as such.
The -text param might work, but using New-UDParagraph willl encase everything in <p>-tags.

Try using New-UDHTML -markup ($content -replace “\r\n”, “
”)

Hi @BoSen29

Thanks for you reply. Maybe my post was slightly faulty. I have content with a line break but universal doeshboard doesn’t show the line break. So the line break is not replaced by
automatically.

$content = “ä” + [environment]::newline + “ö”
New-UDParagraph -Text $content #Show as "ä ö"
New-UDParagraph -Content {$content} #Show as "ä ö"
New-UDParagraph -Text ($content -replace [environment]::Newline,"<br>") #Show as "ä<br>ö"
New-UDParagraph -Content {$content -replace [environment]::Newline,"<br>"} #Show as "ä<br>ö"

As you mentioned New-UDHTML inside the content block works.

New-UDParagraph -Content {New-UDHtml -Markup $($content -replace [environment]::Newline,"<br>")} #Show as "ä" WorkingLineBreak "ö"

But if I use it in a UDGrid, the filter doesn’t work anymore.

Best regards, fabian

Hi @xcabur,

Glad to hear that New-UDHTML works!
Only grids that aren’t working?
Could you try to wrap the markup-field in new-udelement?

New-UDElement -tag span -content {New-UDHTML -markup (markup)}

I have a hunch :slight_smile:

Hi @BoSen29

Only grids that aren’t working?

The line break works with UDHTML in UDGrid too, but the UDGrid filter function does not work anymore. If i don’t use UDHTML line breaks doesn’t work but the filter works :-S

Could you try to wrap the markup-field in new-udelement?

Same behaviour as with UDHTML

Hi again @xcabur

Aaah! This part i’ve seen myself.
The grid will only search for text, and not a UD-component rendered within it.

Could you post a bug report on github for this?

Hi @BoSen29

Sure, I did.
https://github.com/ironmansoftware/universal-dashboard/issues/1633

Thanks for your help, best regards.

1 Like