« lib/Serge/Engine/Plugin/parse_bypass.pm
↑ Summary
lib/Serge/Engine/Plugin/Transform/whitespace.pm »
| 1 | package Serge::Engine::Plugin::parse_keyvalue; | ||||||||||
| 2 | 2 | ▶ | use parent Serge::Engine::Plugin::Base::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | sub name { | ||||||||||
| 7 | 0 | ▶ | return 'Plain key=value string parser'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | sub parse { | ||||||||||
| 11 | 2 | ▶ | my ($self, $textref, $callbackref, $lang) = @_; | ||||||||
|
Subroutine
parse: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | die 'callbackref not specified' unless $callbackref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | my $translated_text = $$textref; | |||||||||
| 16 | |||||||||||
| 17 | # Finding translatable strings in file | ||||||||||
| 18 | |||||||||||
| 19 | # Format is: | ||||||||||
| 20 | # key=value | ||||||||||
| 21 | # key = value | ||||||||||
| 22 | |||||||||||
| 23 | 2 | $translated_text =~ s|^(.+?)(\s*=\s*)(.+)$|$1.$2.$self->parse_callback($callbackref, $3, undef, $1, undef, $lang)|mgie; | |||||||||
| 24 | |||||||||||
| 25 | 2 | return $translated_text; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub parse_callback { | ||||||||||
| 29 | 10 | ▶ | my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang) = @_; | ||||||||
|
Subroutine
parse_callback: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 30 | |||||||||||
| 31 | 10 | my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang, $hint); | |||||||||
| 32 | |||||||||||
| 33 | 10 | $translated_string =~ s/\n/\\n/sg; | |||||||||
| 34 | |||||||||||
| 35 | 10 | return $translated_string; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 2 | 1; | |||||||||