<commit_before>use v6;

use HTML::Template;

my @tests = 
    (
    '<TMPL_LOOP NAME=FOO><TMPL_VAR NAME=IN><TMPL_IF NAME=!LAST>.<TMPL_ELSE>, </TMPL_IF></TMPL_LOOP>',
    FOO => [ {IN => 'a'}, {IN => 'b'}, {IN => 'c'} ],
    'a, b, c.',
    'LAST() return true if last cicle'
    ),
    (
    '<TMPL_LOOP NAME=FOO><TMPL_VAR NAME=IN><TMPL_IF NAME=!FIRST>:<TMPL_ELSE>-</TMPL_IF></TMPL_LOOP>',
    FOO => [ {IN => 'a'}, {IN => 'b'}, {IN => 'c'} ],
    'a:b-c-',
    'LAST() return true if last cicle'
    ),
    ;

use Test;
plan +@tests;

for @tests -> $tmpl, $data, $expected, $descr {
    say $tmpl;
    my $out = HTML::Template.from_string($tmpl).with_params(hash $data).output;
    is($out, $expected, $descr);
}

# vim:ft=perl6<commit_msg>[p6w] fix html-template/09-loop-controls.t a little<commit_after>use v6;


my @tests = 
    (
    '<TMPL_LOOP NAME=FOO><TMPL_VAR NAME=IN><TMPL_IF NAME=!LAST>.<TMPL_ELSE>, </TMPL_IF></TMPL_LOOP>',
    FOO => [ {IN => 'a'}, {IN => 'b'}, {IN => 'c'} ],
    'a, b, c.',
    'LAST() return true if last cicle'
    ),
    (
    '<TMPL_LOOP NAME=FOO><TMPL_VAR NAME=IN><TMPL_IF NAME=!FIRST>:<TMPL_ELSE>-</TMPL_IF></TMPL_LOOP>',
    FOO => [ {IN => 'a'}, {IN => 'b'}, {IN => 'c'} ],
    'a:b-c-',
    'LAST() return true if last cicle'
    ),
    ;

use Test;
plan +@tests;

for @tests -> $tmpl, $data, $expected, $descr {
    use HTML::Template;
    my $out = HTML::Template.from_string($tmpl).with_params(hash $data).output;
    is($out, $expected, $descr);
}

# vim:ft=perl6
{'fraction_non_alphanumeric': 0.23525513585155733, 'fraction_numerical': 0.004638833664678595, 'mean_word_length': 3.339080459770115, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3854411', 'n_tokens_mistral': 676, 'n_tokens_neox': 660, 'n_words': 131}