输出' {{$ NEXT}}'与Text :: Template

时间:2013-05-07 22:30:09

标签: perl plugins dist-zilla texttemplate

Dist :: Zilla的NextRelease插件在Changes文件中查找{{$NEXT}}以放置发布日期时间信息。但是,我无法使用profile.ini生成此内容。这就是我所拥有的:

[GenerateFile / Generate-Changes ]
filename    = Changes
is_template = 1
content = Revision history for {{$dist->name}}
content =
;todo: how can we get this to print correctly with a template?
content = {{$NEXT}}
content =   initial release

{{$dist->name}}被我的分发名称正确替换,但是{{$ NEXT}}原样被替换为什么(因为它没有被转义,并且没有$ NEXT变量)。我已经尝试了不同的斜杠组合来逃避大括号,但它在使用dzil new生成期间不会导致任何错误或错误。如何正确地转义此字符串,以便在dzil处理Text::Template之后输出{{$NEXT}}

1 个答案:

答案 0 :(得分:3)

在内容中,{{$NEXT}}被解释为模板块,正如您所说,希望将自己填充为缺失$NEXT的内容。

相反,请尝试:

content = {{'{{$NEXT}}'}}

示例程序:

use 5.14.0;
use Text::Template 'fill_in_string';
my $result = fill_in_string(
  q<{{'{{$NEXT}}'}}>,
  DELIMITERS => [ '{{', '}}' ],
  BROKEN => sub { die },
);

say $result;