Q&A / syntax

What is the correct Lasso shorthand conditional syntax?

I keep writing condition ? a : b out of habit. What does Lasso use?

Accepted answer by accepted-answer

Lasso uses a question mark followed by the true expression, then a vertical bar before the false expression.
1local(label) = (#count > 0) ? 'has rows' | 'empty'
The colon form belongs to other languages and should not be used in Lasso examples.

Answer by template-user

Inside templates the expression form is useful for small display choices.
1<span class="[#ok ? 'pass' | 'fail']">[#label]</span>
Use a full if block when each branch has several statements.

Related manual category