return $code;
}
+sub yes_no_tag {
+ my ($self, $name, $value) = splice @_, 0, 3;
+ my %attributes = _hashify(@_);
+
+ my $options = $self->options_for_select([ [ 1, $::locale->text('Yes') ], [ 0, $::locale->text('No') ] ], default => $value ? 1 : 0);
+ return $self->select_tag($name, $options, %attributes);
+}
+
sub javascript {
my ($self, $data) = @_;
return $self->html_tag('script', $data, type => 'text/javascript');
default => $actual_vendor_id,
title_sub => sub { $_[0]->vendornumber . " : " . $_[0]->name },
'with_empty' => 1);
-
+
return $self->select_tag($name, $options_str, %params);
}
default => $actual_part_id,
title_sub => sub { $_[0]->partnumber . " : " . $_[0]->description },
'with_empty' => 1);
-
+
return $self->select_tag($name, $options_str, %params);
}
return '<pre>' . Data::Dumper::Dumper(@_) . '</pre>';
}
+sub truncate {
+ my ($self, $text, @slurp) = @_;
+ my %params = _hashify(@slurp);
+
+ $params{at} ||= 50;
+ $params{at} = 3 if 3 > $params{at};
+ $params{at} -= 3;
+
+ return $text if length($text) < $params{at};
+ return substr($text, 0, $params{at}) . '...';
+}
+
1;
__END__
reference then it will be passed to L</options_for_select>
automatically.
+=item C<yes_no_tag $name, $value, %attributes>
+
+Creates a HTML 'select' tag with the two entries C<yes> and C<no> by
+calling L<select_tag> and L<options_for_select>. C<$value> determines
+which entry is selected. The C<%attributes> are passed through to
+L<select_tag>.
+
=item C<input_tag $name, $value, %attributes>
Creates a HTML 'input type=text' tag named C<$name> with the value
L.tab('Awesome tab wih much info', '_much_info.html', if => SELF.wants_all)
+=item C<truncate $text, %params>
+
+Returns the C<$text> truncated after a certain number of
+characters.
+
+The number of characters to truncate at is determined by the parameter
+C<at> which defaults to 50. If the text is longer than C<$params{at}>
+then it will be truncated and postfixed with '...'. Otherwise it will
+be returned unmodified.
+
=back
=head1 MODULE AUTHORS