如何将数组从 weaver.ini 传递到 Pod::Weaver 插件
因此,为了在 weaver.ini
中传递某些内容,插件本身需要一个 Moose 属性。因此,如果我在 weaver.ini
中有类似的内容,
[Acknowledgements]
contributors = 'test foo' 'foo bar'
我的插件中需要一个相应的属性。
has contributors => (
is => 'rw',
isa => 'ArrayRef[Str]',
traits => [ 'Array' ],
default => sub { [ ] },
handles => {
contributors_count => 'count',
},
);
但是,我收到错误
Attribute (contributors) does not pass the type constraint because: Validation failed for 'ArrayRef[Str]' with value 'test foo' 'foo bar' at /home/xenoterracide/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Moose/Meta/Attribute.pm line 1248
,我不确定我哪里出错了。我尝试更改 weaver.ini 中的语法,但似乎并非如此。
So it appears that in order to pass something in weaver.ini
the plugin itself requires a Moose attribute. So if I have something like this in weaver.ini
[Acknowledgements]
contributors = 'test foo' 'foo bar'
I need a corresponding attribute in my plugin.
has contributors => (
is => 'rw',
isa => 'ArrayRef[Str]',
traits => [ 'Array' ],
default => sub { [ ] },
handles => {
contributors_count => 'count',
},
);
However, I'm getting the error
Attribute (contributors) does not pass the type constraint because: Validation failed for 'ArrayRef[Str]' with value 'test foo' 'foo bar' at /home/xenoterracide/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Moose/Meta/Attribute.pm line 1248
I'm not sure where I'm going wrong. I've tried changing the syntax up in weaver.ini
but that doesn't seem to be it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其
.ini
语法略有不同。除此之外,您还必须告诉
Config::MVP
(它负责Dist::Zilla
的配置加载)您的插件的contributor
选项可能有多个值:The
.ini
syntax for that is slightly different.In addition to that, you'll have to tell
Config::MVP
, which is what takes care ofDist::Zilla
's config loading, that your plugin'scontributor
option may have multiple values: