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