top of page

Formatting your data in PnP Modern Search Handlebars makes the difference

  • Writer: Kasper Larsen
    Kasper Larsen
  • 14 minutes ago
  • 1 min read

A colleague of mine asked about enhancing the display of a number, in this case the file size. The output from search looks like 34232 and he asked if it is possible to insert thousand separators, making it look like 34,232.


Similarly, I have been asked repeatedly about how to show a date in a user-friendly way. Personally, I don't understand the question as 2024-04-01T13:26:20.0000000Z looks fint to me.


However, here you are:


ree

Adding the thousand separator turned up to be VERY simple:


{{addCommas (slot item @root.slots.Size)}}


In the PnP Modern Search documentation we link to the Handlebars helpers, and one of the options is just what we need:

ree










The Date formatting is also pretty simple (once you know how):


{{getDate Created 'LL'}}


The helper is documented in the official PnP Modern Search documentation:


ree

ree

Comments


30103817

  • Twitter
  • LinkedIn

©2023 by M365thinking. Proudly created with Wix.com

bottom of page