The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
use Test::More tests => 3;

use Template::Mustache;

is( Template::Mustache->render( '{{ foo.1 }}', { foo => [ 'potato', 'banana' ] } ) => 'banana', 'arrayref' );

{
    package Decs;
    use Moo;

    has some_hash => (
        is      => 'rw',
        default => sub { { 'k1' => 'v1', 'k2' => 'v2' } }
    );

    sub bar { { baz => [ 'quux' ] } }
}

my $self = Decs->new();

is(Template::Mustache->render( '{{ some_hash.k1 }}', $self ), 'v1', 'object with sub-level'  );

is( Template::Mustache->render( '{{ bar.baz.0 }}', $self ) => 'quux', 'all types' );