SID-02082: Custom plugin params _DEFAULT behavior disagreement
| Status: |
Answered |
TWiki version: |
6.0.1 |
Perl version: |
5.10.1 |
| Category: |
EmptyPlugin |
Server OS: |
Linux twiki 2.6.32-431 x86_64 GNU/Linux |
Last update: |
10 years ago |
I'm looking at this comment in
EmptyPlugin.pm:
(sub _EXAMPLEVAR)
# For example, %EXAMPLEVAR{'existence' proof="thinking"}%
# $params->{_DEFAULT} will be 'existence'
# $params->{proof} will be 'thinking'
However, in my custom plugin, called via:
(TWiki raw view)
%RNDB{'names' count="5" gender="male"}%
This code:
(sub _RNDB_Handler)
$debugText .= "_DEFAULT: = $params->{_DEFAULT}<br/>";
$debugText .= "count: = $params->{count}<br/>";
$debugText .= "gender: = $params->{gender}<br/>";
$debugText .= "milieu: = $params->{milieu}<br/>";
$debugText .= "debug: = $params->{debug}<br/>";
I expect to see:
_DEFAULT: = names
count: = 5
gender: = male
milieu: = eng
debug: = 0
(milieu="eng" debug="0" would arrive via the module default values).
What I am seeing is:
_DEFAULT: = 'names' count="5" gender="male"
count: = 24
gender: = any
milieu: = eng
debug: = 0
(ie, the values for milieu, count, gender, etc are all supplied as the module defaults).
Is the %RNDB{...}% malformed?
Is the comment wrong?
r
--
Richard Williamson - 2015-07-02
Discussion and Answer
The example is wrong. Don't mix single quotes and double quotes. I usually use double quotes, e.g.
%EXAMPLEVAR{"existence" proof="thinking"}%.
I'll update the
EmptyPlugin example.
--
Peter Thoeny - 2015-07-02
The
EmptyPlugin comment code example is now updated as follows:
# For example, %EXAMPLEVAR{"to be" or="not to be" that="is the question"}%
# $params->{_DEFAULT} will be 'to be'
# $params->{or} will be 'not to be'
# $params->{that} will be 'is the question'
--
Peter Thoeny - 2015-07-03
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.