Solved Need Mustache Examples to apply custom formating
Hi there,
I need support with mustaches. I went through the following document, but can’t accomplish what I like to do.
https://support.squaredup.com/v3/Reference/Tiles/CustomLabelling#how-to-use-custom-labeling-display-logical-disks-with-a-custom-label-the-mustache-helper
Could you please provide some examples for:
- Condition ( if property == value ) then xxx else yyy
- Condition ( if property >= value ) then xxx else yyy
- Substring
- Replace
- other useful functions you used
Thanks in advance
Ruben
Best answer
Example if statement:
{{#if displayName.toLowerCase() == 'server1.domain.com'}} srv01 {{elseif displayName.toLowerCase() == 'server2.domain.com'}} srv02 {{elseif displayName.toLowerCase() == 'server3.domain.com'}} srv03 {{else}} {{displayName}} {{/if}}
Should just be a case of adjusting == as required, using whichever property works best.
Substrings, I always use this resource:
https://www.w3schools.com/jsref/jsref_substring.asp
Mustache is just using javascript methods against the string.
Replace:
https://www.w3schools.com/jsref/jsref_replace.asp
The Tutorials on the left include everything you could need!
Let us know how you get on 🙂
Answer this question
To reply or comment, use the 'Comment' link on the relevant answer or question.