About template and main layout
Hi All, Because I am new at Dancer, I may be asking easy questions, sorry for this issue. I read document from following link and everything is clear for me : *https://metacpan.org/pod/Dancer2::Tutorial <https://metacpan.org/pod/Dancer2::Tutorial>* 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 %] </div></body></html>* 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: */home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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: /home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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>*
On Wed, Apr 8, 2015 at 10:00 PM, Kadir Beyazlı <kadirbeyazli@gmail.com> wrote:
Hi All,
Because I am new at Dancer, I may be asking easy questions, sorry for this issue. I read document from following link and everything is clear for me :
*https://metacpan.org/pod/Dancer2::Tutorial <https://metacpan.org/pod/Dancer2::Tutorial>*
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 %] </div></body></html>*
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:
*/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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: /home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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>*
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi Kadir,
Welcome to the awesome Dancer world! Due to it being quite late here (12 Midnight) and I've just logged on to work on (another) Dancer application, I would like to suggest only a short 20 minute tutorial which will go through a lot of what you have discussed. I created this for the purpose of showing people a basic setup of Dancer2 and how to get started. https://www.youtube.com/watch?v=O7dO3K-krrg I plan on expanding in the near future and working on some suggestions from people but the video should give a really good idea on how to install the application and dependancies, make changes, create a route and modify the front page. So that might get you started in answering some questions but there are other experts here who can answer specifically the stuff you've raised above, especially if the video does not. Kind Regards, David
Hi David, i will watch video thank you very much 08 Nis 2015 17:37 tarihinde "David H" <untg99@gmail.com> yazdı:
On Wed, Apr 8, 2015 at 10:00 PM, Kadir Beyazlı <kadirbeyazli@gmail.com> wrote:
Hi All,
Because I am new at Dancer, I may be asking easy questions, sorry for this issue. I read document from following link and everything is clear for me :
*https://metacpan.org/pod/Dancer2::Tutorial <https://metacpan.org/pod/Dancer2::Tutorial>*
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 %] </div></body></html>*
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:
*/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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: /home/kadir/DancerExamples/willbe/public/views/mytemplate.tt <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>*
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi Kadir,
Welcome to the awesome Dancer world! Due to it being quite late here (12 Midnight) and I've just logged on to work on (another) Dancer application, I would like to suggest only a short 20 minute tutorial which will go through a lot of what you have discussed. I created this for the purpose of showing people a basic setup of Dancer2 and how to get started. https://www.youtube.com/watch?v=O7dO3K-krrg I plan on expanding in the near future and working on some suggestions from people but the video should give a really good idea on how to install the application and dependancies, make changes, create a route and modify the front page.
So that might get you started in answering some questions but there are other experts here who can answer specifically the stuff you've raised above, especially if the video does not.
Kind Regards,
David
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Wed, 2015-04-08 at 15:30 +0300, Kadir Beyazlı wrote:
get '/' => sub { "hello" };
start;
When I run it and write http://localhost:3000/ to browser I see word 'hello' but I don't see layout info of main.tt.
I haven't checked for sure, but I suspect main.tt is only used when you use the template keyword. You'll need something like: get '/' => sub { template 'hello'; }; Where "hello" is another template called hello.tt
Another problem is that I change code as follow:
get '/' => sub { template 'mytemplate.tt', { 'word' => 'test', }; };
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is not a regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location? Andy
Hi Andrew, 08 Nis 2015 18:41 tarihinde "Andrew Beverley" <andy@andybev.com> yazdı:
On Wed, 2015-04-08 at 15:30 +0300, Kadir Beyazlı wrote:
get '/' => sub { "hello" };
start;
When I run it and write http://localhost:3000/ to browser I see word 'hello' but I don't see layout info of main.tt.
I haven't checked for sure, but I suspect main.tt is only used when you use the template keyword. You'll need something like:
get '/' => sub { template 'hello'; };
Where "hello" is another template called hello.tt
i will check it from manual and test tomorrow.
Another problem is that I change code as follow:
get '/' => sub { template 'mytemplate.tt', { 'word' => 'test', }; };
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is not a regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location?
No. MyApp name is "willbe".
Andy
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Wed, 2015-04-08 at 19:17 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is
^^^^^
not a
regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location?
No. MyApp name is "willbe".
But it's still looking in willbe/public/views - I'd expect it to be looking in just willbe/views, especially as that's where you've said you've put the template.
08 Nis 2015 19:21 tarihinde "Andrew Beverley" <andy@andybev.com> yazdı:
On Wed, 2015-04-08 at 19:17 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is
^^^^^
not a
regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location?
No. MyApp name is "willbe".
But it's still looking in willbe/public/views - I'd expect it to be looking in just willbe/views, especially as that's where you've said you've put the template.
i will check tomorrow from my pc. but it is sure that i did not configure location. i put my .tt file under folder where it was writing at manual. but you are right that it searches .tt file under public folder which was not realized by me when reading error message. i will analysis why it searhes .tt file under public folder because as remember it soul not be there.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi Andrew, My Perl script "test.pl" is under public folder. May this be reason it searches .tt file directory under public folder? 08 Nis 2015 19:29 tarihinde "Kadir Beyazlı" <kadirbeyazli@gmail.com> yazdı:
08 Nis 2015 19:21 tarihinde "Andrew Beverley" <andy@andybev.com> yazdı:
On Wed, 2015-04-08 at 19:17 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is
^^^^^
not a
regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location?
No. MyApp name is "willbe".
But it's still looking in willbe/public/views - I'd expect it to be looking in just willbe/views, especially as that's where you've said you've put the template.
i will check tomorrow from my pc. but it is sure that i did not configure location. i put my .tt file under folder where it was writing at manual. but you are right that it searches .tt file under public folder which was not realized by me when reading error message. i will analysis why it searhes .tt file under public folder because as remember it soul not be there.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Wed, 2015-04-08 at 19:39 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message: /home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is not a regular file or reference
My Perl script "test.pl" is under public folder. May this be reason it searches .tt file directory under public folder?
Quite possibly. Such scripts should be in the bin/ directory.
Hi Andrew, thanks. i put to root folder and it worked. but i will put to /bin folder after this işas you wrote. 08 Nis 2015 19:56 tarihinde "Andrew Beverley" <andy@andybev.com> yazdı:
On Wed, 2015-04-08 at 19:39 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message: /home/kadir/DancerExamples/willbe/public/views/
mytemplate.tt is not a regular file or reference
My Perl script "test.pl" is under public folder. May this be reason it searches .tt file directory under public folder?
Quite possibly. Such scripts should be in the bin/ directory.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, Yes! found it. it worked when i moved perl script to root folder from public folder. i see that this is also reason why main layout was invisible. 08 Nis 2015 19:39 tarihinde "Kadir Beyazlı" <kadirbeyazli@gmail.com> yazdı:
Hi Andrew,
My Perl script "test.pl" is under public folder. May this be reason it searches .tt file directory under public folder? 08 Nis 2015 19:29 tarihinde "Kadir Beyazlı" <kadirbeyazli@gmail.com> yazdı:
08 Nis 2015 19:21 tarihinde "Andrew Beverley" <andy@andybev.com> yazdı:
On Wed, 2015-04-08 at 19:17 +0300, Kadir Beyazlı wrote:
When I open web page I see error message, and at console there is following error message:
/home/kadir/DancerExamples/willbe/public/views/mytemplate.tt is
^^^^^
not a
regular file or reference
It appears to be looking for the template in your public/views directory
content of mytemplate.tt is very simple again
MyApp/views/mytemplate.tt
But your template is in MyApp/views. The latter is where I'd expect it to be, so have you configured your templates to be in an alternative location?
No. MyApp name is "willbe".
But it's still looking in willbe/public/views - I'd expect it to be looking in just willbe/views, especially as that's where you've said you've put the template.
i will check tomorrow from my pc. but it is sure that i did not configure location. i put my .tt file under folder where it was writing at manual. but you are right that it searches .tt file under public folder which was not realized by me when reading error message. i will analysis why it searhes .tt file under public folder because as remember it soul not be there.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (3)
-
Andrew Beverley -
David H -
Kadir Beyazlı