Logical Helpers

Conditional logic and comparison functions that evaluate expressions and return boolean values. These helpers support truthiness evaluation and allow controlling template flow with complex conditional logic.

HelperPurposeParametersReturns
eqTests equalityvalue1, value2boolean
neTests inequalityvalue1, value2boolean
ltTests less thanvalue1, value2boolean
leTests less than or equalvalue1, value2boolean
gtTests greater thanvalue1, value2boolean
geTests greater than or equalvalue1, value2boolean
inTests value in collectionneedle, ...haystackboolean
notLogical NOTvalueboolean
andLogical AND...valuesboolean
orLogical OR...valuesboolean

Falsy and Truthy Values

In logical expressions, the following values are considered falsy and will evaluate to false:

Any other value is considered truthy and will evaluate to true.

eq

Tests if two values are equal.

Syntax:

{{#eq value1 value2}}

Parameters:

Returns: true if values are equal, false otherwise

Examples:

{{#if (eq model.name "MyClass")}}
  <div class="my-class-documentation">
    {{model.doc.summary}}
  </div>
{{/if}}

{{#if (eq @index 0)}}
  <div class="first-item">
{{/if}}

ne

Tests if two values are not equal.

Syntax:

{{#ne value1 value2}}

Parameters:

Returns: true if values are not equal, false otherwise

Examples:

{{#if (ne model.name "MyClass")}}
  <div class="other-class-documentation">
    {{model.doc.summary}}
  </div>
{{/if}}

{{#if (ne @index 0)}}
  <span class="separator">, </span>
{{/if}}

lt

Tests if the first value is less than the second.

Syntax:

{{#lt value1 value2}}

Parameters:

Returns: true if value1 < value2, false otherwise

Examples:

{{#if (lt @index 5)}}
  <span class="limited-display">{{this}}</span>
{{/if}}

{{#if (lt model.parameters.count 3)}}
  <span class="simple-method">Simple</span>
{{/if}}

le

Tests if the first value is less than or equal to the second.

Syntax:

{{#le value1 value2}}

Parameters:

Returns: true if value1 <= value2, false otherwise

Examples:

{{#if (le model.declaredMembers.count 10)}}
  <div class="show-all">
{{else}}
  <div class="show-summary">
{{/if}}

gt

Tests if the first value is greater than the second.

Syntax:

{{#gt value1 value2}}

Parameters:

Returns: true if value1 > value2, false otherwise

Examples:

{{#if (gt model.declaredMethods.length 0)}}
  <section class="methods">
    <h2>Methods</h2>
{{/if}}

{{#if (gt @index 0)}}
  <hr class="separator">
{{/if}}

ge

Tests if the first value is greater than or equal to the second.

Syntax:

{{#ge value1 value2}}

Parameters:

Returns: true if value1 >= value2, false otherwise

Examples:

{{#if (ge model.metadata.nestedTypes 1)}}
  <div class="nested-types">
{{/if}}

{{#if (ge @index 0)}}
  <div class="valid-index">
{{/if}}

in

Tests if a value exists in a collection.

Syntax:

{{#in value haystack}}
{{#in value value1 value2 value3 ...}}

Parameters:

Returns: true if value is found in collection, false otherwise

Examples:

{{#if (in (format model.modelType) 'Class' 'Struct' )}}
  <div class="compound-type">
{{/if}}

{{#if (in (format model.modelType) allowedCategories)}}
  <div class="allowed-category">
{{/if}}

not

Logical NOT operation.

Syntax:

{{#not value}}

Parameters:

Returns: true if value is falsy, false if value is truthy

Examples:

{{#if (not model.metadata.isStatic)}}
  <div class="instance-member">
{{/if}}

{{#if (not @first)}}
  <span class="separator"> | </span>
{{/if}}

and

Logical AND operation.

Syntax:

{{#and values}}
{{#and value1 value2 value3 ...}}

Parameters:

Returns: true if all values are truthy, false otherwise

Examples:

{{#if (and model.metadata.isPublic model.isIndexer)}}
  <div class="documented-public-index-property">
{{/if}}

{{#if (and (gt @index 0) (lt @index 10))}}
  <div class="middle-range">
{{/if}}

or

Logical OR operation.

Syntax:

{{#or values}}
{{#or value1 value2 value3 ...}}

Parameters:

Returns: true if any value is truthy, false otherwise

Examples:

{{#if (or model.isStatic model.isReadOnly)}}
  <div class="special-member">
{{/if}}

{{#if (or @first @last)}}
  <div class="boundary-item">
{{/if}}