BarefootJS-Backend-Xslate

 view release on metacpan or  search on metacpan

t/render.t  view on Meta::CPAN

like $out, qr/bf-s="Widget_test" bf-r=""/, 'scope + hydration markers (raw)';
like $out, qr{count: <!--bf:s0-->7<!--/-->}, 'reactive text slot with comment markers';
like $out, qr/&lt;x&gt;/, 'plain interpolation is auto-escaped';
like $out, qr/<span class="c" id="n">/, 'spread_attrs renders raw with sorted keys';

# Fragment-rooted scope comment pair (#2289): `renderFragment`'s Kolon
# output shape — begin marker, children, end marker — rendered through
# the real engine so the `| mark_raw :>` filter chain is exercised, not
# just the underlying Perl subs.
{
    open my $fh, '>:encoding(UTF-8)', File::Spec->catfile($dir, 'frag.tx') or die $!;
    print $fh <<'TX';
<: $bf.scope_comment() | mark_raw :><span>A</span><span><: $count :></span><: $bf.scope_comment_end() | mark_raw :>
TX
    close $fh;

    my $frag_backend = BarefootJS::Backend::Xslate->new(path => [$dir]);
    my $frag_bf = BarefootJS->new(undef, { backend => $frag_backend });
    $frag_bf->_scope_id('FragmentDemo_test');

    my $frag_out = $frag_backend->render_named('frag', $frag_bf, { count => 3 });

    like $frag_out, qr/^<!--bf-scope:FragmentDemo_test-->/, 'begin marker leads the fragment';
    like $frag_out, qr/<!--bf-\/scope:FragmentDemo_test-->\s*$/, 'end marker trails the fragment, same scope id';
}

# Backend unit operations.
is $backend->materialize('plain'), 'plain', 'materialize: scalar passthrough';
is $backend->materialize(sub { 'lazy' }), 'lazy', 'materialize: resolves CODE ref';
like $backend->encode_json({ b => 2, a => 1 }), qr/^\{"a":1,"b":2\}$/,
    'encode_json: canonical key order';

done_testing;



( run in 0.856 second using v1.01-cache-2.11-cpan-364913b4093 )