gt

Reports whether the value is greater than the given number, comparing both as numbers so 5 and 5.0 rank the same.

Both sides have to be dates. A printed one becomes a real one through from_date, and it is not read here, because a modifier that took a string would have to guess how the value is written and would answer confidently either way. An argument is a name or a literal and never a pipe, so the other side of the comparison is a date the caller already resolved, and a date the template computes is compared through days_between instead.

InputArgumentsReturnstime.Timetime.Timeboolfloat64float64bool
Source
BasicSource

Compares two dates, so a template can ask whether a deadline is still ahead. Both sides have to be real dates rather than printed ones.

Given

{"expires_at": time.Date(2024, 4, 1, 0, 0, 0, 0, time.UTC), "today": time.Date(2024, 3, 14, 0, 0, 0, 0, time.UTC)}

Template

{{ expires_at | gt:today }}

Result

true
BasicSource

Reports whether the value is greater than the operand, comparing numerically across the int and float kinds.

Given

{"score": 82}

Template

{{ score | gt:70 }}

Result

true
BelowSource

Returns false when the value does not exceed the operand.

Given

{"score": 50}

Template

{{ score | gt:70 }}

Result

false
FloatSource

Compares fractional values numerically, so 4.5 exceeds 4.

Given

{"rating": 4.5}

Template

{{ rating | gt:4 }}

Result

true
NegativeSource

Shows a negative value is not greater than zero.

Given

{"balance": -5}

Template

{{ balance | gt:0 }}

Result

false