UserTag widget-info	Order	name attribute
UserTag widget-info	Version	1.1
UserTag	widget-info	Routine	<<EOR
my %wi_attr = ((map { (lc $_, $_) } qw(
	Widget
	Documentation
	Visibility
	Description
	Help
	Multiple
	Version
)), qw(
	exists	Widget
));

sub {
	my ($name, $attr) = @_;

	if (length $name) {
		# Global or Local?
		my $repo = $Global::CodeDef->{Widget};
		$repo = $Vend::Cfg->{CodeDef}{Widget} if $Vend::Cfg->{CodeDef}{Widget}{Widget}{$name};
		return unless $repo->{Widget}{$name};

		if (length $attr) {
			# return just one attribute for the given name.
			$attr = $wi_attr{lc $attr} or return;
			return $repo->{$attr}{$name};
		}
		else {
			# return a hashref with all the available attributes for a given name.
			my %build = reverse %wi_attr;
			while (my $key = each %build) {
				if (exists $repo->{$key}{$name}) {
					$build{$key} = $repo->{$key}{$name};
				}
				else {
					delete $build{$key};
				}
			}
			return \%build;
		}
	}
	else {
		# return a hashref of hashrefs for all the widgets and their attributes.
		my %build = %{$Global::CodeDef->{Widget}{Widget}};
		@build{keys %build} = ($Global::CodeDef->{Widget}) x scalar keys %build;
		@build{keys %{$Vend::Cfg->{CodeDef}{Widget}{Widget}}} = ($Vend::Cfg->{CodeDef}{Widget}) x scalar keys %{$Vend::Cfg->{CodeDef}{Widget}{Widget}};

		foreach my $name (keys %build) {
			my $repo = $build{$name};
			$build{$name} = {reverse %wi_attr};
			while (my $key = each %{$build{$name}}) {
				if (exists $repo->{$key}{$name}) {
					$build{$name}{$key} = $repo->{$key}{$name};
				}
				else {
					delete $build{$name}{$key};
				}
			}
		}
		return \%build;
	}
}
EOR
