1#!perl -T
2
3use strict;
4use warnings;
5use Test::More;
6use Tenjin;
7
8my $t = Tenjin->new({ path => ['t/data/layout_precedence'], layout => 'instance_layout.html' });
9ok($t, 'Got a proper Tenjin instance');
10
11my $context = { msg => 'hello world', arrayref => [qw/my name is Tenjin/] };
12
13# no layout should be used
14is(
15	$t->render('content.html', $context, 0),
16	'<p>hello world, my name is Tenjin</p>',
17	'Rendering without a layout works'
18);
19
20# layout should be used from $_context->{_layout}
21$context->{_layout} = 'context_layout.html';
22is(
23	$t->render('content.html', $context, 'render_layout.html'),
24	'<xml><p>hello world, my name is Tenjin</p></xml>',
25	'Rendering into context-defined layout works'
26);
27
28# layout should be used from render
29is(
30	$t->render('content.html', $context, 'render_layout.html'),
31	'<html><p>hello world, my name is Tenjin</p></html>',
32	'Rendering into render-defined layout works'
33);
34
35# layout should be used from Tenjin instance
36is(
37	$t->render('content.html', $context),
38	'<null><p>hello world, my name is Tenjin</p></null>',
39	'Rendering into instance-defined layout works'
40);
41
42done_testing();
43