### ----------------------------------------------------
### -- Template::Nest::Fast
### -- Licenses: ISC
### -- Authors: Andinus <andinus@nand.sh>
### -- File: t/06-token-delims.rakutest
### ----------------------------------------------------
use Test;
use Template::Nest::Fast;

plan 3;

my IO $output-dir = $*PROGRAM.IO.parent.add('output');
my IO $template-dir = $*PROGRAM.IO.parent.add('templates');

my $nest = Template::Nest::Fast.new( :$template-dir, :token-delims('<%', '%>') );
my $nest-underscored = Template::Nest::Fast.new( :$template-dir, :token_delims('<%', '%>') );

my $nest-alt = Template::Nest::Fast.new( :$template-dir, :token-delims('<%', '%>'), :fixed-indent );

my %simple-page = %(
    TEMPLATE => '00-simple-page-alt-delim',
    variable => 'Simple Variable',
    simple_component => %(
        TEMPLATE => '01-simple-component-alt-delim',
        variable => 'Simple Variable in Simple Component'
    )
);

# test simple page with alternate token delims.
is(
    $nest.render(%simple-page),
    $output-dir.add('01-simple-page.html').slurp,
    "Simple page with alternate token delim is rendered."
);

is(
    $nest-underscored.render(%simple-page),
    $nest.render(%simple-page),
    "Simple page with alternate token delim is rendered [& underscored option]."
);

my %simple-page-alt = %(
    TEMPLATE => '00-simple-page-alt-delim',
    variable => 'Simple Variable',
    simple_component => %(
        TEMPLATE => '02-simple-component-multi-line-alt-delim'
    )
);

# test simple page with alternate token delims & fixed-indent = True.
is(
    $nest-alt.render(%simple-page-alt),
    $output-dir.add('07-simple-page-fixed-indent.html').slurp,
    "Simple page with alternate token delim & fixed-indent is rendered."
);


