PmWiki | PITS / 01529: new conditional markup condition "empty" (original) (raw)

Summary: new conditional markup condition "empty"

Created: 2025-11-11 19:17

Status: Closed, added for 2.5.4

Category: Feature

Assigned:

Priority: 3

Version: latest

OS: n/a

Description: I propose

(:if empty STRING:)

true if VARIABLE or STRING is empty or does not exist

to replace the construct

(:if equal "STRING" "":)

simon November 11, 2025, at 07:17 PM

Should a value of "0" be considered empty, like the PHP empty() function? Or these values? Petko November 11, 2025, at 07:33 PM

(:if empty:) true (:if empty :) true (:if empty "":) true (:if empty {$NoSuchVar}:) true (:if empty "{$NoSuchVar}":) true (:if empty 0:) false, string is '0' (:if empty "0":) false, string is '0' (:if empty false:) false, string is 'false' (:if empty "false":) false, string is 'false' (:if empty var=value:) false, string is 'var=value' (:if empty var=0:) false, string is 'var=0' (:if empty var="":) false, string is 'var=""'

No, I see this as 'string' comparison, I've added what I would expect to be returned above.
true and false can be evaluated using the existing Conditional Markup (:if expr EXPRESSION :)

This PITS does not ask for numeric evaluation (but see something similar at 01469)

See also

PITS /

01136 change PTV use in pagelists to be more intuitive (Open)

01209 Add more markup expressions to the core (Open)

01469 Extend ConditionalMarkup with "less" and "greater" operators (Open)

Agreed, added for 2.5.4. Petko November 11, 2025, at 08:53 PM