| Text-Snippet documentation | Contained in the Text-Snippet distribution. |
Text::Snippet::TabStop::WithDefault - Tab stop that specifies a default value for the user
version 0.04
${1:default value here}
This method parses the index and default value from the source that is passed in.
Returns the default value as parsed from the original source of the tab stop.
Augments super-class' replacement method an returns the default value if no replacement has been specified.
Brian Phillips <bphillips@cpan.org>
This software is copyright (c) 2010 by Brian Phillips.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Text-Snippet documentation | Contained in the Text-Snippet distribution. |
package Text::Snippet::TabStop::WithDefault; BEGIN { $Text::Snippet::TabStop::WithDefault::VERSION = '0.04'; } # ABSTRACT: Tab stop that specifies a default value for the user use strict; use warnings; use base qw(Text::Snippet::TabStop); use Carp qw(croak); use Class::XSAccessor getters => { default => 'default' }; sub replacement { my $self = shift; return $self->has_replacement ? $self->SUPER::replacement : $self->default; } sub parse { my $class = shift; my $src = shift; if($src =~ m/\$\{(\d+):(.*)\}/){ return $class->_new( index => $1, src => $src, default => $2 || '' ); } return; } 1; __END__