You are here: TWiki> Codev Web>ExtractParameters (2004-08-29, PeterThoeny)
Tags:
create new tag
, view all tags

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

 
WebForm
TopicClassification FeatureDone
TopicSummary Plugins: New TWiki::Func::extractParameters Function to extract all parameters from a variable string
InterestedParties

AssignedTo

AssignedToCore PeterThoeny
ScheduledFor CairoRelease
RelatedTopics

SpecProgress 100%
ImplProgress 100%
DocProgress 100%
Topic revision: r1 - 2004-08-29 - 08:05:46 - PeterThoeny
 
TWIKI.NET
This site is powered by the TWiki collaboration platform
Ideas, requests, problems regarding TWiki? Send feedback
Copyright © 1999-2009 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.