Skip Menu |

This queue is for tickets about the Acme-PPIx-MetaSyntactic CPAN distribution.

Report information
The Basics
Id: 127883
Status: resolved
Priority: 0/
Queue: Acme-PPIx-MetaSyntactic

People
Owner: Nobody in particular
Requestors: james2vegas [...] aim.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: theme attribute is ineffective
neither setting the PERL_METASYNTACTIC_THEME environment variable (for perl-metasyntactic) nor setting the theme attribute on the Acme::PPIx::MetaSyntactic constructor affects the variable names in the output, they remain from the 'haddock' theme;  this applies to passing both strings ('dilbert', f.e.) or Acme::MetaSyntactic objects.

perl 5.24.3; Moo 
2.003004; Type::Tiny 1.004002; Acme::MetaSyntactic 1.014
The following code

        use Acme::PPIx::MetaSyntactic;
        use feature 'say';
        # my $acme = "Acme::PPIx::MetaSyntactic"->new(theme => 'dilbert', document => \<<'END');
         my $acme = "Acme::PPIx::MetaSyntactic"->new(theme => Acme::MetaSyntactic->new('dilbert'), document => \<<'END');                                   
        use constant PLACE => "World";
 
        sub join_spaces {
           return join " ", @_;
        }
 
        my @greetings = qw(Hello);
 
        say join_spaces($greetings[0], PLACE);
        END
 
        say $acme->document;
 
produces the following output

        use constant PROFITEUR => "World";
 
        sub cyclotron {
           return join " ", @_;
        }
 
        my @terroriste = qw(Hello);
 
        say cyclotron($terroriste[0], PROFITEUR);
 

On Sat Dec 01 23:09:55 2018, JWRIGHT wrote: Show quoted text
> neither setting the PERL_METASYNTACTIC_THEME environment variable (for > perl-metasyntactic) nor setting the theme attribute on the > Acme::PPIx::MetaSyntactic constructor affects the variable names in > the output, > they remain from the 'haddock' theme; this applies to passing both > strings > ('dilbert', f.e.) or Acme::MetaSyntactic objects.
I have encountered the same issue. For a reason that is not clear to me yet, this line in _get_name my $name = $self->theme->name; always calls `_build_theme`, even when a `theme` argument is passed to the constructor. Actually, I think it's because the trigger for the `document` is called before the coercion for `theme`. Since that trigger calls `relabel_subs` which in turns calls `_get_name`, `_build_theme` ends up being called while the object is still being built, and before the coercion for the `theme` argument can be called. And so, whatever we try, we always end up with the default theme. -- BooK
Fixed in 0.004.