[dancer-users] Dancer2: Rendering markdown to HTML

Joel Roth joelz at pobox.com
Fri Nov 27 05:17:30 EST 2020

There's simple (if not trivial) solution with a splat, FWIW.  
Probably there's a better way to specify the path. 

I was distracted looking for something more magical.



use Text::Markdown 'markdown';
use File::Slurper 'read_text';

get '**' => sub {
    my ($route) = splat; 
    say "route: @$route";
    my @route = @$route;
    my $file = pop @route;
    $file .= '.md';
    my $path = path(dirname($0), '..', 'lib', 'md', @route , $file);
    pass if not -r $path;
    say "path: $path";
    my $md = read_text($path);
    say "markdown: $md";
    my $content = markdown($md);
    say "content: $content";
    template 'index' => { title => 'mimizufarm', 'content' => $content }

Joel Roth

More information about the dancer-users mailing list