Add isTrue() to TWiki::Func
Currently TWiki uses
TWiki::isTrue to determine whether a boolean option to a tag represents true or false.
The values interpreted are
1,
0,
on,
off.
The proposal is to:
- Extend the range of values to recognise
true, false, yes and no.
- Add
isTrue to TWiki::Func for the benefit of plugins authors.
=pod
isTrue( $value, $default ) -> $boolean
Returns 1 (true) if
$value is
true, and 0 otherwise.
true means set to
something that Perl interprets as a Perl true value, i.e. anything except the empty string
or numeric
0, with the special cases that
off,
false and
no (case insensitive) all mean
false. Leading and
trailing spaces in
$value are ignored.
If (and only if)
$value is
undef then
$default is returned. If
$default is
not specified it is taken as 0 (false).
Since: $TWiki::Plugins::VERSION 1.13
=cut
Note that the pod doc on
TWiki::isTrue is currently wrong;
false is currenty interpreted as
true.
Bugs:Item3806
--
Contributors: CrawfordCurrie - 25 Mar 2007
Discussion
Sounds like a very useful extension to me which will make life easier for plugin authors. And fully compatible.
--
KennethLavrsen - 25 Mar 2007
Good idea; no-brainer.
--
PeterThoeny - 25 Mar 2007
No concern raised. No need for release meeting decision. Accepted by 14-day rule.
--
KennethLavrsen - 09 Apr 2007