Share via

What is the syntax for conditional formatting within PnP Modern Search WebPart template?

MikeRodgers 1 Reputation point
2022-07-14T18:25:58.917+00:00

Hello,

I am trying to figure out the syntax for the PnP Search WebPart so that I may apply conditional formatting.

In this case, I would like to see if a column value is empty - then I would apply X CSS and if a column value's length is less than 2 , then apply this Y CSS.

Conventionally, I would imagine it would be something like this if the value is empty :
{{#if slot.item @root .,slots.Title.value empty}}
<div>..CSS here </div>
{{/if}}

AND something like this if the string length is greater than 2 :
{{#if slot.item @root .,slots.Title.value >len(2)}}
<div>..CSS here </div>
{{/if}}

I would very much appreciate any assistance.

Regards,
Mike

Microsoft 365 and Office | SharePoint | Development

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.