简体   繁体   中英

Output '{{$NEXT}}' with Text::Template

The NextRelease plugin for Dist::Zilla looks for {{$NEXT}} in the Changes file to put the release datetime information. However, I can't get this to be generated using my profile.ini. Here's what I have:

[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}} is correctly replaced with my distribution name, but {{$NEXT}} is, as-is, replaced with nothing (since it's not escaped and there is no $NEXT variable in). I've tried different combinations of slashes to escape the braces, but it either results in nothing or an error during generation with dzil new . How can I properly escape this string so that after dzil processes it with Text::Template it outputs {{$NEXT}} ?

In the content, {{$NEXT}} is being interpreted as a template block and, as you say, wants to fill itself in as the contents of the missing $NEXT .

Instead, try:

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

Example program:

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

say $result;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM