From 876037c029b1133751d6cb63aa13ef1646e67cb2 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Wed, 23 Aug 2017 14:22:28 +1000 Subject: [PATCH] * render html comments --- lib/CMTD/Main.pm | 3 ++- templates/main/list.html.ep | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 templates/main/list.html.ep diff --git a/lib/CMTD/Main.pm b/lib/CMTD/Main.pm index 901bd19..32e9ff9 100644 --- a/lib/CMTD/Main.pm +++ b/lib/CMTD/Main.pm @@ -47,7 +47,8 @@ sub c_list { # TODO: processing @cm = @tm; } - $self->render(json => \@cm); + $self->stash(comments => \@cm); + $self->respond_to(json => {json => \@cm}, any => {template => 'main/list'}); } else { $self->client_reply(400, "no such site"); } 1; diff --git a/templates/main/list.html.ep b/templates/main/list.html.ep new file mode 100644 index 0000000..a060290 --- /dev/null +++ b/templates/main/list.html.ep @@ -0,0 +1,14 @@ +% my $comments = stash('comments') || []; +
+% foreach my $cm (@{ $comments }) { +
+
+ <%= tag span => (class => 'cmtd_num') => $cm->{seq} %>, + <%= tag span => (class => 'cmtd_name') => $cm->{name} %>, + <%= tag span => (class => 'cmtd_date') => $cm->{date} %>, + <%= link_to 'Reply' => '#', class => 'reply', 'date-id' => $cm->{seq} %> +
+ <%= tag 'div' => (class => 'cmtd_text') => $cm->{text} %> +
+% } +