Hi Monks!

I have a simple program that checks for user activities in an application.
I am starting to use Mojo Lite, it seems to be really good.
I am using my script by calling it from the browser as: http://www.myplace.com/mycode.pl/
It loads the main template, shows the initial page no problem. What I can not understand is why the
value on this line $c->stash( title => ' This is the text for the title' ); does not show
on the template, neither does this one $c->stash( result => ' This is the result for  testing' );
in the "/get_status" route.
I am also trying to stop these debug messages:
[debug] GET "/" [debug] Routing to a callback [debug] 200 OK (0.007915s, 126.342/s) [debug] GET "/get_status"
to be logged every time I call the script from
the browser. New to this and appreciate any help!

Here is a sample of the code I have:
#!/usr/bin/perl use Mojolicious::Lite; plugin 'HTMLTemplateProRenderer'; use Mojo::JSON qw(decode_json encode_json); use HTML::Template; use Data::Dump 'pp'; # dbh attribute app->attr(dbh => sub { my $c = shift; # I set a connection to the DB my $dbh = ...; # Passing connections in a hashref my $pass_dbh = {'dbh' => $dbh }; return $pass_dbh; }); any '/' => sub { my $c = shift; # Load Main Template $c->render( template => 'main', ); # Cant get this to show on the main template. $c->stash( title => ' This is the text for the title' ); }; get '/get_status' => sub { my $c = shift; my $get_update = $c->req->query_params->param('update'); # SQL goes here - this code is only for showing my logic my $data = (<<SQL); SELECT ... SQL # Load value into Main template, # but I cant get the results to display on the template. $c->render( template => 'main', ); # this is the tag in the template <TMPL_VAR NAME="result"> $c->stash( result => ' This is the result for testing' ); # I also return json from the sql query results, called from ajax # and it works fine. return $c->render(json => $data ); }; app->start;
Thanks for helping!

In reply to Loading values into template using Perl and Mojolicious::Lite by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.