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)MindTouch.Deki.Script.DekiScriptBadTypeException: nil is not valid; expected num or str
at MindTouch.Deki.Script.DekiScriptMap.get_Item (MindTouch.Deki.Script.DekiScriptLiteral index) [0x00000]
at MindTouch.Deki.Script.DekiScriptAccess.Evaluate (MindTouch.Deki.Script.DekiScriptEnv env, Boolean evaluateProperties) [0x00000]
at MindTouch.Deki.Script.DekiScriptAccess.Evaluate (MindTouch.Deki.Script.DekiScriptEnv env) [0x00000]
at MindTouch.Deki.Script.DekiScriptBinary.Evaluate (MindTouch.Deki.Script.DekiScriptEnv env) [0x00000]
at MindTouch.Deki.Script.Dom.DekiScriptDomExpr.Evaluate (MindTouch.Deki.Script.DekiScriptEvalContext context, System.Xml.XmlNode parent, MindTouch.Deki.Script.DekiScriptEnv env) [0x00000] |