<div dir="ltr"><div><div><div><div>Dear Andrew,<br><br></div>Thanks. Following is keyword for me.<br><br><i><b>The layout is just a part of the template functionality </b>which you can use to return web pages.</i><br>
<br></div>Dear David,<br><br></div>Your solution below worked, thanks.<br><br>get '/' => sub {<br>
# get the template engine<br>
my $template_engine = engine 'template';<br>
<br>
# apply the layout (not the renderer), and return the result<br>
return $template_engine->apply_layout("Home Page");<br>
};<br><br> I think the other solution is calling a template as follow<br><br><i>get '/' => sub {<br> template '<a href="http://dummy.tt">dummy.tt</a>', {<br> 'msg' => 'Home Page',<br> };<br><br></i></div><div><i><b><a href="http://dummy.tt">dummy.tt</a></b><br></i></div><i><% msg %><br></i><div><i><br></i><br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 21, 2015 at 3:27 PM, David Precious <span dir="ltr"><<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, 21 May 2015 12:08:32 +0100<br>
Andrew Beverley <<a href="mailto:andy@andybev.com">andy@andybev.com</a>> wrote:<br>
> On Thu, 2015-05-21 at 13:04 +0300, Kadir Beyazlı wrote:<br>
> > <a href="http://main.tt" target="_blank">main.tt</a> is loaded if I use a template at my code.<br>
> > What is the reason <a href="http://main.tt" target="_blank">main.tt</a> is not loaded if I don't use a template?<br>
><br>
> The idea is that you can have full control as to what you return to<br>
> the browser. For example, you might want to return only some simple<br>
> plain text, or maybe send a file to the browser, in which case<br>
> wrapping in the main layout would break things.<br>
<br>
</span>^ This is indeed the right answer - applying the layout is part of the<br>
template processing - so if you've used template() to generate content<br>
from a template, the layout is applied, but if you've just returned<br>
content, it's assumed that that's the content you want sent to the<br>
client - in other words, whatever the route handler returns is what<br>
goes to the client, whether that's the result of a template() call, or<br>
just some content you generated.<br>
<br>
If you want to apply the layout around some generated content without<br>
having to put it in a template file, you can use the template engine's<br>
apply_layout() method to do it, e.g.:<br>
<br>
get '/' => sub {<br>
# get the template engine<br>
my $template_engine = engine 'template';<br>
<br>
# apply the layout (not the renderer), and return the result<br>
return $template_engine->apply_layout("Home Page");<br>
};<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
David Precious ("bigpresh") <<a href="mailto:davidp@preshweb.co.uk">davidp@preshweb.co.uk</a>><br>
<a href="http://www.preshweb.co.uk/" target="_blank">http://www.preshweb.co.uk/</a> <a href="http://www.preshweb.co.uk/twitter" target="_blank">www.preshweb.co.uk/twitter</a><br>
<a href="http://www.preshweb.co.uk/linkedin" target="_blank">www.preshweb.co.uk/linkedin</a> <a href="http://www.preshweb.co.uk/facebook" target="_blank">www.preshweb.co.uk/facebook</a><br>
<a href="http://www.preshweb.co.uk/cpan" target="_blank">www.preshweb.co.uk/cpan</a> <a href="http://www.preshweb.co.uk/github" target="_blank">www.preshweb.co.uk/github</a><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><b><i>Kadir Beyazlı<br>Computer Engineer</i></b></div><div><b><i>GSM : +90 535 821 50 00</i></b><br></div></div></div>
</div>