On Thu, 2015-05-21 at 13:04 +0300, Kadir Beyazlı wrote:
main.tt is loaded if I use a template at my code. What is the reason main.tt is not loaded if I don't use a template?
The idea is that you can have full control as to what you return to the browser. For example, you might want to return only some simple plain text, or maybe send a file to the browser, in which case wrapping in the main layout would break things. If you use the "template" keyword, then the chances are you're displaying a standard web page, in which case it will be helpfully be wrapped in your main template, as that's probably what you would want.
For example, at following code, why main.tt is loaded at login page (get '/login') but not loaded at Home Page (get '/' )?
get '/' => sub { return "Home Page"; };
Here you're returning only the content "home page". If you want the text to be wrapped in the layout, then you will need to put it in a template and use the template keyword. The short of it is that whatever you return from your route is what gets sent to the browser. The layout is just a part of the template functionality which you can use to return web pages. Andy