Want to have a condition checked up in a method in jsview

38 Views Asked by At

I am new to JsViews. In one of the template, I have to set multiple conditions for rendering :

<tr>
            {{if condition1 || condition2 || condition3}}
            <td class="formLabel"
                style="padding-left:2px;vertical-align:middle;text-align:left;font-size:8pt;font-family:sans-serif;"
                width=""><span id="{{attr:firstChild().id()}}_labelSpan" style="color:#000000;">{{attr:childAtIndex_(1).paramAt_('label')}}</span>
            </td>
            <td style="vertical-align:middle;" width="200px">{{:renderChildren()}}</td>
            {{else}}
            <td style="vertical-align:middle;" width="200px">{{:renderChildren()}}</td>
            <td class="formLabel"
                style="padding-left:2px;vertical-align:middle;text-align:left;font-size:8pt;font-family:sans-serif;"
                width=""><span id="{{attr:firstChild().id()}}_labelSpan" style="color:#000000;">{{attr:childAtIndex_(1).paramAt_('label')}}</span>
            </td>
            {{/if}}
        </tr>`

Can I put the multiple condition in the a method at the template level

1

There are 1 best solutions below

0
On

Yes, you can do that. See the documentation on "Paths and expressions".

As examples, see the sample at the bottom of the {{if}} tag topic, which does:

{{if members && members.length}}
  ...
{{else standby && standby.length}}
  Standby only:
  ...
{{else}}
  No members!
{{/if}}

This sample also shows examples of using expressions in JsRender tags, such as:

{{if address && address.street}}

and

{{:~lateMessages.noAddress || ~messages.noAddress}}