Closed sharepointmike closed 5 years ago
The syntax for {{if}}
is {{if ~PanelSize}} .... {{else}} ... {{if}}
So in your case it would be
<div {{if ~PanelSize}}class="{{:~PanelSize}}"{{else}}class="ms-Panel ms-Panel--xxl"{{/if}}>
Or better, perhaps:
<div class="{{if ~PanelSize}}{{:~PanelSize}}{{else}}ms-Panel ms-Panel--xxl{{/if}}">
Alternatively you can use ternary expressions:
<div class="{{:~PanelSize?~PanelSize:'ms-Panel ms-Panel--xxl'}}">
or even simpler with a ||
<div class="{{:~PanelSize||'ms-Panel ms-Panel--xxl'}}">
If you are using JsViews data-linking, you can instead use a data-linked expression:
<div data-link="class{:~PanelSize||'ms-Panel ms-Panel--xxl'}">
Thanks a lot Boris!!
I call my template like this:
This worked fine but now I added the "PanelSize" parameter which sometimes is used and sometimes is not. So in my template I try to do this:
<div {{if {{:~PanelSize}} }} class={{:~PanelSize}} {{else}}class="ms-Panel ms-Panel--xxl"{{/if}}>
But what kind of variant I use, it's not working (wrong syntax errors). What is the correct syntax to do this? So if the parameter is send, it is used. Otherwise the default is used. Thanks a lot for the help