For more information... RTFM!
NAVIGATION
RECENTLY VIEWED
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

line2options

Replaces newlines (any combination of "\r" and "\n" in the body text) with commas.  It also takes care of removing any leading and trailing whitespace from all entries.

Also see the options2line filter.

Example

[filter line2options]
One
Two
Three
[/filter]

Results in:

One,Two,Three

Source code

sub {
    my ($value, $tag, $delim) = @_;
    return $value unless length $value;

    $value =~ s/\s+$//;
    $value =~ s/^\s+//;
    my @opts = split /[\r\n]+/, $value;

    for(@opts) {
        s/^\s+//;
        s/[,\s]+$//;
        s/,/,/g;
    }
    return join ",", @opts;
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Monday 26 February 2007 at 11:52 AM (EST)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us