読者です 読者をやめる 読者になる 読者になる

Text::Xslate 3.2.4 is out

perl xslate

https://metacpan.org/release/Text-Xslate


Text::Xslate 3.2.4 is out.

Changes

  • Fix for blead Perl
  • add first and last method for arrays

Fix for blead Perl

Perl changes representation of unused Array slots from Perl 5.19.4 and
this causes segmentation fault before version 3.2.3. We fixed this issue
and We can use Text::Xslate with Perl 5.19.4 or higher.

first and last method

https://github.com/xslate/p5-Text-Xslate/issues/116


These methods are for only readability. We can access
first or last element by index, but it is not sometimes
easy for non-programmers, like designers.

Sample Code for 'first' and 'last'

#!/usr/bin/env perl
use strict;
use warnings;

use Text::Xslate '3.2.4';

my $tx = Text::Xslate->new();

print $tx->render_string(
    'first: <: $data.first() :>, last: <: $data.last() :>', {
        data => [1..10]
    });
print "\n";


This output is

first: 1, last: 10


Before 3.2.3, we need to write as below

print $tx->render_string(
    'first: <: $data[0] :>, last: <: $data[-1] :>', {
        data => [1..10]
    });


You think it is more readable than latter version, don't you ?

Conclusion

Please report us via github issues if you have any problems or suggestions.