<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Have you enabled Template Toolkit in the config?<div class=""><br class=""><div class="">
--<br class="">Clive Eisen<br class="">GPG: 75056DD0<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 18 Oct 2017, at 06:28, Gavin Colborne <<a href="mailto:gavin@littleforest.co.uk" class="">gavin@littleforest.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Dancers,<div class=""><br class=""></div><div class="">I am pretty new to Dancer and really like the light nature of the framework.</div><div class=""><br class=""></div><div class="">I am trying to create a route which will show data from a MongoDB collection and struggling with the syntax.</div><div class=""><br class=""></div><div class="">I have the following in my app:</div><div class=""><br class=""></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><div class=""><font face="monospace, monospace" class="">sub connect_mongo {</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""> my $client = MongoDB->connect('<a href="mongodb://a.b.c.d" class="">mongodb://a.b.c.d</a>') or die "Error connecting to Mongo";</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""><span style="white-space:pre" class=""> </span>my $db = $client->get_database( 'lfi-perl' );</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""><span style="white-space:pre" class=""> </span>return($db);</font></div></div><div class=""><div class=""><font face="monospace, monospace" class="">}</font></div></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><div class=""><font face="monospace, monospace" class="">get '/mongo' => sub {</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""> my $db = connect_mongo();</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""><span style="white-space:pre" class=""> </span>my $docs = $db->get_collection( 'Test-Collection' );</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""><span style="white-space:pre" class=""> </span>my $all_docs;</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""> template '<a href="http://show_mongo.tt/" class="">show_mongo.tt</a>', {</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""> 'entries' => $all_docs = $docs->find(),</font></div></div><div class=""><div class=""><font face="monospace, monospace" class=""> };</font></div></div><div class=""><div class=""><font face="monospace, monospace" class="">};</font></div></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class="">Then in my view the following:</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class="">[% FOREACH id IN entries.keys.nsort %]</font></div><div class=""><div class=""><font face="monospace, monospace" class=""> </font></div></div><div class=""><div class=""><font face="monospace, monospace" class="">[% entries.$id._id %]</font></div></div></blockquote><div class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I am not able to see any data in my view but am also not seeing any errors.</div><div class=""><br class=""></div><div class="">Any examples of getting data from Mongo in Dancer would be really helpful.</div><div class=""><br class=""></div><div class="">Thank you in advance,</div><div class=""><br class=""></div><div class="">Gavin</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Best Regards,<br class=""><br class="">Gavin Colborne<br class=""><br class="">Managing Director,<br class=""><br class="">Tele: 0207 193 2014<br class="">Mobile: 0788 400 4339<br class="">Skype: gavincolborne<br class="">Visit: <a href="http://www.littleforest.co.uk/" target="_blank" class="">www.littleforest.co.uk</a><br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><a href="http://www.littleforest.co.uk/" style="font-family: 'Times New Roman'; font-size: inherit;" target="_blank" class=""><img src="http://www.littleforest.co.uk/wp-content/uploads/2017/02/1.jpg" alt="Little Forest LFi" class=""></a><br class=""></div></div></div></div></div></div></div>
</div></div>
_______________________________________________<br class="">dancer-users mailing list<br class=""><a href="mailto:dancer-users@dancer.pm" class="">dancer-users@dancer.pm</a><br class="">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users<br class=""></div></blockquote></div><br class=""></div></body></html>