Preserving Whitespace Jelly script

adam_webster
Kilo Contributor

Hi,

I'm working on a dynamic content block and im struggling on preserving the white space.

I want to maintain the white space between the apostrophes: news   += ('             ')

Any suggestions?

Script:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

  <j2:whitespace trim="false">

  <span style="color:red">

    <g:evaluate>

        var news = '' ;

      var kb = new GlideRecord('kb_knowledge');

      var now = gs.dateGenerate(gs.yesterday(), 'end');

      kb.addQuery('valid_to', '>', now);

      kb.addQuery('topic','News');

  kb.addQuery('category', 'NewsFlash');

      kb.addQuery('workflow_state','published');

      kb.query();

  while (kb.next()){

  (news == '') ? news = kb.short_description.toString()   : news   += ('             ')   + kb.short_description.toString();

}

  </g:evaluate>

<j:while test="${kb.next()}">

<j:if test="${kb.canRead()}">

     

  <g:evaluate>

  news +=   kb.short_description + ('                   ');

 

  </g:evaluate>

</j:if>

</j:while>

  <marquee behavior="scroll" direction="left"><b>${news} </b></marquee>

  </span>

  </j2:whitespace>

</j:jelly>

Thanks,

Adam

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee

I always have a good bit of trouble with jelly stripping out white spacing event when using ${SP}. What I usually do is use a div with a margin to add the space. So something like:



<marquee behavior="scroll" direction="left"><div style="font-weight:bold;margin-right:10px">${news}</div></marquee>


View solution in original post

9 REPLIES 9

Anurag Tripathi
Giga Patron

'& n b s p; ' worked fine for me...without spaces in between and without quotes. Replying to this is a big pain as each time its replacing it with a space



Infact if you reply to this comment with writing that without quotes it prints a blank only


I was wondering would It be possible   to have a link in the marquee which directs the user to the record?


should work


im having no luck with   the clicking on the display results within the marquee and directing the user to contents of the record



Any suggestions?


hyperlink in a marquee is no biggie, im sure you are stuck somewhere else. Can you show you code and describe what you are trying to achieve?