[PW-dev] parameter names (dash, underscore, none)
Status: Alpha
Brought to you by:
spadkins
|
From: Stephen A. <ste...@of...> - 2001-06-19 16:18:59
|
Hi,
I continue to work on the next mini-release of the
Perl Widget Library. I have incorporated a number
of parameters from style sheets such as "border-style", etc.
Usage looks like this.
$last_name = $wc->widget(
-name => "last_name",
-widget_class => "Widget::HTML::TextField",
-size => 8, # from HTML spec
-maxlength => 18, # from HTML spec
-color => "#6666CC", # from CSS spec
-font_size => "10px", # from CSS spec
-border_style => "solid", # from CSS spec
-border_width => "1px", # from CSS spec
-border_color => "#6666CC", # from CSS spec
-padding => "2px", # from CSS spec
-background_color => "#ccffcc", # from CSS spec
-font_family => "Verdana, Geneva, Arial", # from CSS spec
-override => 1, # increase precedence of options to
"override" from "default"
-validate => "date", # "date", "time", "datetime", "enum",
"number", "integer", ":regexp"
)->html();
However, this presents a stylistic dilemma with parameter names.
If I use "border-style", the syntax would be
$last_name = $wc->widget(
-border-style => "solid",
)->html();
However, this fails because "-border-style" cannot be a bareword.
I have so far opted to changed dashes in attribute names to underscores.
This is the first option.
Alternatively, the second option is to remove the dash like so.
$last_name = $wc->widget(
-borderstyle => "solid",
)->html();
Alternatively, the third (and least attractive option to me) is to
require the programmer to quote the named parameter like so.
$last_name = $wc->widget(
"-border-style" => "solid",
)->html();
I have chosen option #1.
How do you all feel?
Stephen
|