AND/OR for if/unless
Closed this issue · 2 comments
vladsavchuk commented
It would be nice to have AND/OR operators to avoid multiple nested conditional structures like:
<~no_id unless="id" inline>
<~no_cars_id unless="context[cars_id]" inline>
<~no_contacts_id unless="context[contacts_id]" inline>
<a class="btn btn-default" href="...">`Existing Client`</a>
</~no_contacts_id>
</~no_cars_id>
</~no_id>
osalabs commented
Generally it's not a best practice to put too much (business) logic into templates, therefore ParsePage only allows if/unless
and some if
options for simple comparisons.
Instead - keep all complex logic in the backend code (PHP, .NET, etc...).
In your case it's better to do this:
$ps = array(
'is_show_btn' => !$id && !$context['cars_id'] && !$context['contacts_id']
);
then template will be much simpler and clean:
<~btn if="is_show_btn" inline>
<a class="btn btn-default" href="...">`Existing Client`</a>
</~btn>
vladsavchuk commented
Okay, got it. Views is for 'views'.