Index: lib/TWiki/If.pm =================================================================== --- lib/TWiki/If.pm (revision 13708) +++ lib/TWiki/If.pm (working copy) @@ -251,6 +251,21 @@ return 0; }, }, + { + name => 'isempty', + prec => 5, + arity => 1, # unary + casematters => 0, + exec => sub { + my( $session, $a ) = @_; + my $eval = $a->evaluate($session); + return 1 unless $eval; + return 0 if ( $session->{cgiQuery}->param( $eval )); + return 0 if ( $session->{prefs}->getPreferencesValue( $eval )); + return 0 if ( $session->{SESSION_TAGS}{$eval} ); + return 1; + }, + }, @cmpOps, ); Index: data/TWiki/IfStatements.txt =================================================================== --- data/TWiki/IfStatements.txt (revision 13708) +++ data/TWiki/IfStatements.txt (working copy) @@ -32,6 +32,7 @@ | =~= | regular expression match (use perl regular expressions) | | context | True if the current context is set (see below) | | defined | True if a preference variable or url parameter of this name is defined. | +| empty | True if a preference variable or url parameter of this name has an empty value. | | $ | expands a URL parameter or [[TWikiVariables][TWikiVariable]]. Plugin handlers *are not called*. Built-in variables and user-defined preferences are supported. You can pass a limited subset of parameters to TWiki variables by enclosing the variable name in single quotes; for example, =$ 'VARIABLE{value}'=. The ='VARIABLE{value}'= string may *not* contain quotes (' or "). | examples: Index: test/unit/Fn_IF.pm =================================================================== --- test/unit/Fn_IF.pm (revision 13708) +++ test/unit/Fn_IF.pm (working copy) @@ -19,6 +19,7 @@ $this->{twiki}->enterContext('test'); $TWiki::cfg{Fnargle} = 'Fleeble'; $TWiki::cfg{A}{B} = 'C'; + $TWiki::cfg{A}{EMPTY} = ''; my $u = $this->{twiki}->{users}; my @tests = ( { test => 'A=B', then=>0, else=>1 }, @@ -28,6 +29,7 @@ { test => 'context test', then=>1, else=>0 }, { test => '{Fnargle}=Fleeble', then=>1, else=>0 }, { test => '{A}{B}=C', then=>1, else=>0 }, + { test => 'isempty {A}{EMPTY}', then=>1, else=>0 }, { test => '$ WIKINAME = '.$u->getWikiName($this->{twiki}->{user}), then=>1, else=>0 }, { test => 'defined EDITBOXHEIGHT', then=>1, else=>0 },