Tags:
create new tag
view all tags

SID-02082: Custom plugin params _DEFAULT behavior disagreement

Status: Answered 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

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Custom plugin params _DEFAULT behavior disagreement
SupportCategory EmptyPlugin
TWiki version 6.0.1
Server OS Linux twiki 2.6.32-431 x86_64 GNU/Linux
Web server Apache 2.2.15 (Unix)
Perl version 5.10.1
Browser & version Safari 8.0.7 (MacOS client)
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2015-07-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.