[dancer-users] Dancer2: Rendering markdown to HTML

Joel Roth joelz at pobox.com
Fri Nov 27 02:28:39 EST 2020


Hi List,

I'd like to author pages as markdown files and 
render them when requested.

I've done something similar in Dancer, now
trying Dancer2.

Hoping for an easy result using Dancer2::Plugin::MarkdownFilesToHTML.

I am trying to get a result from this route:

localhost:5000/doc/home

But I can't seem to hook up the route with the 
rendering, and only get 404. The setup I tried follows
below.

An alternative would be capturing the route with a **
and rendering the page in the route handler. 
Does anyone have examples of this?

Thanks for any ideas!

config.yml
==========

appname: "mimizufarm"

layout: "main"

charset: "UTF-8"

template: "simple"

auto_page: 1

plugins:
  MarkDownFilesToHTML:
    defaults:
      prefix: doc
      file_root: lib/md
      template: index.tt
      layout: main.tt
      generate_toc: 0
      linkable_headers: 0
    routes:
      - home:
          resource: 'home.md'


lib/mimizufarm.pm
=================

package mimizufarm;
use Dancer2;
use Dancer2::Plugin::MarkdownFilesToHTML;

our $VERSION = '0.1';

get '/' => sub {
    template 'index' => { 'title' => 'mimizufarm' };
};

true;


-- 
Joel Roth


More information about the dancer-users mailing list