[dancer-users] About template and main layout

Kadir Beyazlı kadirbeyazli at gmail.com
Wed Apr 8 13:30:39 BST 2015

Hi All,

Because I am new at Dancer, I may be asking easy questions, sorry for this
I read document from following link and everything is clear for me :


I understood full example which is located at the end of page.
But I tried a very very simple example and it failed!.

Here it is

I have file called *test.pl <http://test.pl>* with very simple content:

*MyApp/public/test.pl <http://test.pl> *

*use Dancer2;use Template;set 'layout'    => 'main';set 'template'  =>
'template_toolkit';get '/' => sub {     "hello"};start;*

When I run it  and write *http://localhost:3000/ <http://localhost:3000/>*
to browser I see word 'hello' but I don't see layout info of main.tt. Its
content is below :

*MyApp/views/layouts/main.tt <http://main.tt><!doctype html><html><head>
<title>Test</title></head><body>  <div>  Before content  [% content %]

I expect to see yellow backgrounded word *"Before content"* but I don't see.

Another problem is that I change code as follow:

*MyApp/public/test.pl <http://test.pl> *

*use Dancer2;use Template;set 'layout'    => 'main';set 'template'  =>
'template_toolkit';get '/' => sub {    template 'mytemplate.tt
<http://mytemplate.tt>', {        'word' => 'test',  };};start;*
When I open web page I see error message, and at console there is following
error message:

<http://mytemplate.tt> is not a regular file or reference at
/usr/local/share/perl/5.20.1/Dancer2/Core/Role/Template.pm line 126. in
/usr/local/share/perl/5.20.1/Dancer2/Core/App.pm l. 1145[main:5105] error
@2015-04-08 15:06:48> Route exception:
<http://mytemplate.tt> is not a regular file or reference at
/usr/local/share/perl/5.20.1/Dancer2/Core/Role/Template.pm line 126. in
/usr/local/share/perl/5.20.1/Dancer2/Core/App.pm l. 1145*
content of *mytemplate.tt <http://mytemplate.tt>* is very simple again

*MyApp/views/mytemplate.tt <http://main.tt><div>[% word %]</div>*
What is wrong ?

*Kadir BeyazlıComputer Engineer*
*GSM : +90 535 821 50 00 <%2B90%20535%20821%2050%2000>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150408/f69c8209/attachment.html>

More information about the dancer-users mailing list