[ic] Modifications to Selected and Checked Coretags

Mike Heins mike at perusion.com
Fri Oct 17 01:09:53 EDT 2003

Quoting Mat Jones (mat at thinkopensource.com):
> I have made some minor modifications to the [selected] and [checked] 
> coretags (4.9.8) to allow a delimiter="" option to be specified. If 
> delimiter="foo" is used then multiple="1" is assumed and not required. The 
> tag is backward compatible, so anyone currently using multiple="1" will not 
> have any issues.
> Example usage (with a comma delimited list):
> <select name="mail_list" MULTIPLE>
> <option value="newsletter" [selected name="mail_list" value="newsletter" 
> delimiter=","]>newsletter
> <option value="upgrade" [selected name="mail_list" value="upgrade" 
> delimiter=","]>upgrade
> </select>

> The diffs are below. Hope its of some use :)

A good deal of use. It works fine, and passes all of the 
regression tests (I have some pretty good ones for those).

Those who know me realize I can't keep my hands off of someone
else's good patch, so I had to change it to:

	if ($opt->{multiple}) {
	    my $be;
	    my $ee;
	    $opt->{delimiter} = "\0" unless defined $opt->{delimiter};

	    if (length $opt->{delimiter}) {
		my $del = Vend::Interpolate::get_joiner($opt->{delimiter}, "\0");
		$be = '(?:^|' . $del . ')'; ;
		$ee = '(?:$|' . $del . ')'; ;
	    else {
		$be = '';
		$ee = '';

	    my $regex = qr/$be\Q$value\E$ee/;
	    return ' SELECTED' if $ref =~ $regex;

This allows a defined but empty delimiter:

    foo=[value name=foo set="ab|ceg"]
    [loop list="a b c d e f g |"]
    [loop-code]:[selected name=foo value="[loop-code]" multiple=1 delimiter=""]<br>

This can be useful for concatenating one-letter/digit options for storage
without a delimiter.

Thank you for an excellent suggestion and excellent code implmenting it.
These are in CVS and will be in the next nightly build.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike at perusion.com>

If you think nobody cares if you're alive, try missing a couple of
car payments.  -- Earl Wilson

More information about the interchange-users mailing list