| 1 | package WWW::MenuGrinder::Plugin::Hotkey; | ||
| 2 | BEGIN { | ||
| 3 | $WWW::MenuGrinder::Plugin::Hotkey::VERSION = '0.06'; | ||
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: WWW::MenuGrinder plugin that generates hotkeys from labels. | ||
| 7 | |||
| 8 | use Moose; | ||
| 9 | |||
| 10 | with 'WWW::MenuGrinder::Role::ItemMogrifier'; | ||
| 11 | |||
| 12 | sub item_mogrify { | ||
| 13 | my ($self, $item) = @_; | ||
| 14 | |||
| 15 | return $item unless exists $item->{label}; | ||
| 16 | |||
| 17 | if ($item->{label} =~ s#_(.)#<u>$1</u>#) { | ||
| 18 | $item->{hotkey} = uc $1 unless defined $item->{hotkey}; | ||
| 19 | } | ||
| 20 | |||
| 21 | return $item; | ||
| 22 | } | ||
| 23 | |||
| 24 | __PACKAGE__->meta->make_immutable; | ||
| 25 | |||
| 26 | no Moose; | ||
| 27 | 1; | ||
| 28 | |||
| 29 | |||
| 30 | __END__ |