<div dir="ltr">Thanks Richard, that looks really helpful, I will try it later on today and let you know :)</div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
<tr>
<td style="width:55px;padding-top:13px"><a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-green-avg-v1.png" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
<td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avg.com</a>
</td>
</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Best Regards,<br><br>Gavin Colborne<br><br>Managing Director,<br><br>Tele: 0207 193 2014<br>Mobile: 0788 400 4339<br>Skype: gavincolborne<br>Visit: <a href="http://www.littleforest.co.uk/" target="_blank">www.littleforest.co.uk</a><br></div><div dir="ltr"><br></div><div dir="ltr"><a href="http://www.littleforest.co.uk/" style="font-family:"Times New Roman";font-size:medium" target="_blank"><img src="http://www.littleforest.co.uk/wp-content/uploads/2017/02/1.jpg" alt="Little Forest LFi"></a><br></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On 18 October 2017 at 10:13, Richard Jones <span dir="ltr"><<a href="mailto:ra.jones@dpw.clara.co.uk" target="_blank">ra.jones@dpw.clara.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>I've been caught by that before. Try <font face="monospace,
monospace">[% entries.$id.item('_id') %]. For some reason (would
interested to learn what), TT doesn't seem to be able to cope
with leading underscores in data structures. You can prove
entries contains data using:</font></p>
<font face="monospace, monospace">[% USE Dumper(Indent=1) %]</font><br>
<font face="monospace, monospace">[% FOREACH id IN entries %]</font><br>
<font face="monospace, monospace"> <pre>[% Dumper.dump(id)
%]</pre></font><br>
[% END %]<br>
<br>
or just <font face="monospace, monospace">[% Dumper.dump(entries)
%]<br>
<br>
</font>
<div class="m_-9035457219841122134moz-cite-prefix">On 18/10/2017 06:28, Gavin Colborne
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Dancers,
<div><br>
</div>
<div>I am pretty new to Dancer and really like the light nature
of the framework.</div>
<div><br>
</div>
<div>I am trying to create a route which will show data from a
MongoDB collection and struggling with the syntax.</div>
<div><br>
</div>
<div>I have the following in my app:</div>
<div><br>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div><font face="monospace, monospace">sub connect_mongo {</font></div>
</div>
<div>
<div><font face="monospace, monospace"> my $client =
MongoDB->connect('mongodb://a.<wbr>b.c.d') or die "Error
connecting to Mongo";</font></div>
</div>
<div>
<div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>my
$db = $client->get_database( 'lfi-perl' );</font></div>
</div>
<div>
<div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>return($db);</font></div>
</div>
<div>
<div><font face="monospace, monospace">}</font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
<div>
<div><font face="monospace, monospace">get '/mongo' =>
sub {</font></div>
</div>
<div>
<div><font face="monospace, monospace"> my $db =
connect_mongo();</font></div>
</div>
<div>
<div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>my
$docs = $db->get_collection( 'Test-Collection' );</font></div>
</div>
<div>
<div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>my
$all_docs;</font></div>
</div>
<div>
<div><font face="monospace, monospace"> template '<a href="http://show_mongo.tt" target="_blank">show_mongo.tt</a>',
{</font></div>
</div>
<div>
<div><font face="monospace, monospace"> 'entries'
=> $all_docs = $docs->find(),</font></div>
</div>
<div>
<div><font face="monospace, monospace"> };</font></div>
</div>
<div>
<div><font face="monospace, monospace">};</font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">Then in my view the
following:</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">[% FOREACH id IN
entries.keys.nsort %]</font></div>
<div>
<div><font face="monospace, monospace"> </font></div>
</div>
<div>
<div><font face="monospace, monospace">[% entries.$id._id %]</font></div>
</div>
</blockquote>
<div>
<div><br>
</div>
<div><br>
</div>
<div>I am not able to see any data in my view but am also not
seeing any errors.</div>
<div><br>
</div>
<div>Any examples of getting data from Mongo in Dancer would
be really helpful.</div>
<div><br>
</div>
<div>Thank you in advance,</div>
<div><br>
</div>
<div>Gavin</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br clear="all">
<div>
<div class="m_-9035457219841122134gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">Best Regards,<br>
<br>
Gavin Colborne<br>
<br>
Managing Director,<br>
<br>
Tele: 0207 193 2014<br>
Mobile: 0788 400 4339<br>
Skype: gavincolborne<br>
Visit: <a href="http://www.littleforest.co.uk/" target="_blank">www.littleforest.co.uk</a><br>
</div>
<div dir="ltr"><br>
</div>
<div dir="ltr"><a href="http://www.littleforest.co.uk/" target="_blank"><img src="http://www.littleforest.co.uk/wp-content/uploads/2017/02/1.jpg" alt="Little Forest LFi"></a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="m_-9035457219841122134mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
dancer-users mailing list
<a class="m_-9035457219841122134moz-txt-link-abbreviated" href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a>
<a class="m_-9035457219841122134moz-txt-link-freetext" href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/<wbr>mailman/listinfo/dancer-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<pre class="m_-9035457219841122134moz-signature" cols="72">--
Richard Jones</pre>
</font></span></div>
<br>______________________________<wbr>_________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/<wbr>mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>