Skip to main content Link Search Menu Expand Document Toggle dark mode Copy Code (external link)
paperwork.help

( ) : Parentheses

Groups part of an expression so it is evaluated first, before the operators around it.


On this page

Syntax

{{(expression) operator value}}

Examples

Without parentheses, operators are evaluated by precedence - multiplication before addition.

Data:

builder.WithData("model", new { price = 10, shipping = 5, qty = 2 });

Template:

<p>{{(model.price + model.shipping) * model.qty}}</p>
<p>{{model.price + model.shipping * model.qty}}</p>
<p>{{(model.qty > 1) &amp;&amp; (model.price &lt; 20)}}</p>

Output:

30
20
True

Notes

  • Parentheses can be nested: {{((a + b) * c) / d}}.
  • Use them to make comparisons and calculations clear, even where the precedence would give the same result.
  • In an attribute value, <, > and & are written &lt;, &gt; and &amp;.
  • Parentheses after a function name are the function’s arguments, e.g. {{round(model.price * 1.2, 2)}}.

See Also