Table of contents
  1. 1. Usage Restrictions
  2. 2. Samples

Tests for nil.  First, the expression to the left of the ?? operator is evaluated.  If the resulting value is nil, the expression to the right is evaluated and returned instead.

Usage Restrictions

1.8.2 or later.

Samples


Output

To test for nil:

{{ nil ?? "Nil detected" }}

Nil detected

To display the language name of a page, or a default value if the language is not found:

{{ {"en": "English", "de": "German"}[page.language] ?? "Not found!" }} 

/content/body/div[2]/table/tbody/tr[3]/td[2]/p[1]/span, nil is not valid; expected num or str (click for details)

 

Tag page (Edit tags)
    You must login to post a comment.