Implemented: New TWiki::Func::extractParameters Function to extract all parameters from a variable string
extractParameters( $attr ) ==> %params
Description: |
Extract all parameters from a variable string and returns a hash of parameters |
Parameter: $attr |
Attribute string |
Return: %params |
Hash containing all parameters. The nameless parameter is stored in key _DEFAULT |
Since: |
TWiki::Plugins::VERSION 1.025 (26 Aug 2004) |
- Example:
- Variable:
%TEST{ "nameless" name1="val1" name2="val2" }%
- First extract text between
{...}
to get: "nameless" name1="val1" name2="val2"
- Then call this on the text:
my %params = TWiki::Func::extractParameters( $text );
- The
%params
hash contains now:
_DEFAULT => "nameless"
name1 => "val1"
name2 => "val2"
This function complements the existing TWiki::Func::extractNameValuePair function. TWiki::Func::ExtractParameters is faster if you have several parameters to extract.
Contributors:
--
PeterThoeny - 29 Aug 2004
Discussions
This was a simple addition for Cairo, so that Plugin authors can use it if needed.
After Cairo we can improve some places of the core code that use repeated extractNameValuePair calls.
I am aware of Crawford's Attrs function. The Attrs parsing differs from TWiki::Func::extractNameValuePair; Wiki::Func::extractParameters parsing is the same as TWiki::Func::extractNameValuePair.
--
PeterThoeny - 29 Aug 2004