firstof Tag

Logic

Argument(s): arguments

Documentation

Returns the first argument in a list of arguments that evaluates to True.

Variables

a = False
b = 0
c = ""
d = "hello"

Template

{% firstof a b c d %}

Result

hello

The tag allows for a default string literal:

{% firstof a b c d "goodbye" %}

The default string will be used if all of the preceding arguments evaluate to False.


Did we get something wrong? Is there a use case for the firstof tag that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Sept. 16, 2020, 7:33 p.m. EST