Tags:
create new tag
, view all tags
In the DEVELOP codebase, most parameterised tags, such as %TAG{param="value"}% are parsed by a single method and dispatched to handler functions. It has been discussed before that plugins should be able to register their own handler functions here, a concept which I support.

A natural extension to this would be to allow registrants to specify types for the parameters to the tag. This would support the idea of centralised parameter type checking proposed by MichaelSparks.

The important thing here is the type set. Obviously "text" has to be supported, for plaintext values. But there's a strong case for a range of other types:

Types:

  • general - text string, using \" to escape quotes
  • numeric - (atomic) integer or float
  • range - (atomic) number in a range
  • date - (atomic) could use Time::ParseDate for flexible parsing, or constrain dates to TWiki syntax ( dd Mmm yyyy )
  • topic - atomic) wikiword or web.wikiword
  • web - (atomic) valid existing web name
  • user - (atomic) wikiname of a user
  • boolean - (atomic) 1, 0, yes, no, true, false, on, off
  • list(atom) - comma separated list of atomic types
  • regex - a regular expression that has to be matched by the value, such as "\d+" for an integer
  • callback - ref to a callback function that can be called to verify the type. The callback would be a function that takes two parameters, a ref to the session object and the string representing the data to be checked. It would return an error message if the check failed.

For example, a plugin could register a tag in it's BEGIN block thus:

TWiki::registerTag( "MYTAG", { param1 => "boolean", param2 => \&TWiki::Plugins::MyPlugin::typecheck, param3 => "list(date)" } );

-- CrawfordCurrie - 17 Jan 2005

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2005-01-25 - WillNorris
 
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.