%TAG{fred="bad" "sad" joe="mad"}%
An attribute set is a map containing an entry for each parameter. The
default parameter (unnamed quoted string) is named __default__
in the map.
Attributes declared later in the string will override those of the same
name defined earlier. Escaping quotes is not supported.
The parser is forgiving; it will handle standard TWiki syntax (parameter values double-quoted) but also single-quoted values, unquoted spaceless values, spaces around the =, and commas as well as spaces separating values.
$string
- String containing attribute specification
$friendly
- if true, the parse will be according to the extended syntax pioneered by the original Contrib::Attrs. Otherwise it will be strict as per traditional TWiki syntax.
Parse a standard attribute string containing name=value pairs and create a new attributes object. The value may be a word or a quoted string. If there is an error during parsing, the parse will complete but $attrs->{_ERROR} will be set in the new object.
Extended syntax example:
use TWiki::Contrib::Attrs; my $attrs = new TWiki::Contrib::Attrs('the="time \\"has come", "the walrus" said to=speak of=\'many \\'things\', 1);In this example:
the
will be time "has come
__default__
will be the walrus
said
will be on
to
will be speak
of
will be many 'things
Only " and ' are escaped.
Traditional syntax is as old TWiki, except that the whole string is parsed (the old parser would only recognise default values in position 1, nowhere else)
$key | Attribute name |
$key | Attribute to remove |
remove
the attribute is no longer defined.
AttrsContrib.zip
in your twiki installation directory. Content:
File: | Description: |
---|---|
data/TWiki/AttrsContrib.txt | |
lib/TWiki/Contrib/Attrs.pm | |
lib/TWiki/Contrib/AttrsContrib/test.zip | |
lib/TWiki/Contrib/AttrsContrib/build.pl |
Author: | TWiki:Main/CrawfordCurrie http://www.c-dot.co.uk |
Copyright ©: | 2001, Motorola Corp, All Rights Reserved |
License: | GPL |
Dependencies: | None |
Change History: | |
14/08/04 | Separated out from SharedCode? module |
Home: | http://TWiki.org/cgi-bin/view/Plugins/AttrsContrib |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/AttrsContribDev |
Related Topics: TWikiPreferences
-- TWiki:Main/CrawfordCurrie - 12:53:50 16 August 2004