REST Resource adding Javascript


(Nick Papadatos) #1

Matrix Version: 5.5.4

Hi Squiz folk, I have a rest asset and I’m trying to add the following of code.

This is ok
print('<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>');

But how do I add the following script to the rest asset?

    <script>
        var dateMonthAsWord = moment("2019-12-23").format('DD MM YY');
    </script>

I’m trying to control the date format in the display output to 23 12 2019

Cheers
N


(Byrne) #2

So you can:

  • nest the REST asset in a page and include that Script that calls moment after it.
  • process the date change directly on the data returned in the REST response server side.

processing everything server side is a faster way to process the page.


(Nick Papadatos) #3

Too easy, thanks Andrew

NickyP