[dancer-users] How to data into webpage

Attila Bárdi attila.bardi at gmail.com
Thu Aug 20 10:56:54 BST 2015


I splited into three part:

1, the first is the route handler, AJAX  backend, ...

get '/' => sub {
  template 'rootTemplate', {

ajax '/getAll' => sub {
  my $allHashRef = HelperModule->fetchAll_hashref();

 foreach ( keys %$trac) {
        push @_, {
            value => "$_",
            text => "$trac->{$_}",
    return to_json(\@_);

        return to_json(\@_);

2, data visualization: template toolkit, bootstrap, jquery, ...
3, data gathering in separated Perl module

In the separated Perl modul I do all of the queries, updates, creation and
returning the object, hashes, arrays, ... to the caller.
In this way I can do more efficient testing and a code reusing for example
in a Perl script.

On Thu, Aug 20, 2015 at 4:17 AM, Richard Reina <gatorreina at gmail.com> wrote:

> Have been learning Dancer2 over the last few weeks and really like it.
> Wondering if someone can tell me how I can load data from a MySQL database
> into a dancer rendered page. I am comfortable writing SQL in perl via
> perl->DBI just don't have any idea how to bring the data from a fetch into
> a webpage so that I can display it directly on the page or load it into a
> dropdown menu. Any help is greatly appreciated.
> Thanks
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150820/7c482c7c/attachment.html>

More information about the dancer-users mailing list