Mercurial > pub > Impl
comparison Lib/IMPL/Resources/Format.pm @ 368:010ceafd0c5a
form metadata + tests
author | cin |
---|---|
date | Wed, 04 Dec 2013 17:31:53 +0400 |
parents | 4d0e1962161c |
children | 2f16f13b000c |
comparison
equal
deleted
inserted
replaced
367:608e74bc309f | 368:010ceafd0c5a |
---|---|
9 sub FormatMessage { | 9 sub FormatMessage { |
10 my ($string,$args,$resolver) = @_; | 10 my ($string,$args,$resolver) = @_; |
11 | 11 |
12 $args ||= {}; | 12 $args ||= {}; |
13 $resolver ||= \&_defaultResolver; | 13 $resolver ||= \&_defaultResolver; |
14 $string ||= ''; | |
14 | 15 |
15 $string =~ s/%(\w+(?:\.\w+)*)%/_getvalue($args,$1,"\[$1\]",$resolver)/ge; | 16 $string =~ s/%(\w+(?:\.\w+)*)%/_getvalue($args,$1,"\[$1\]",$resolver)/ge; |
16 | 17 |
17 return $string; | 18 return $string; |
18 } | 19 } |
26 $obj = $obj->{$chunk}; | 27 $obj = $obj->{$chunk}; |
27 } else { | 28 } else { |
28 $obj = $resolver->($obj,$chunk); | 29 $obj = $resolver->($obj,$chunk); |
29 } | 30 } |
30 } | 31 } |
31 return $obj; | 32 return $obj||'<undef>'; |
32 } | 33 } |
33 | 34 |
34 sub _defaultResolver { | 35 sub _defaultResolver { |
35 my ($obj,$prop) = @_; | 36 my ($obj,$prop) = @_; |
36 | 37 |