bobtfish / text-markdown

The perl Text::Markdown CPAN module
Other
50 stars 21 forks source link

support first argument of markdown as blessed string like Text::Xslate::Type::Raw. #16

Open tokuhirom opened 13 years ago

tokuhirom commented 13 years ago

markdown with xslate.

This is a example failing code:

use strict;
use warnings;
use utf8;
use File::Spec;
use File::Basename;
use lib File::Spec->catdir(dirname(__FILE__), 'extlib', 'lib', 'perl5');
use lib File::Spec->catdir(dirname(__FILE__), 'lib');
use Plack::Builder;
use Amon2::Lite;

use Text::Xslate qw/html_builder mark_raw/;
use Text::Markdown qw/markdown/;

sub config {
    +{
        'Text::Xslate' => {
            'function' => {
                markdown     => html_builder { Text::Markdown::markdown(@_) },
            },
        }
    }
}

get '/markdown_sample' => sub { $_[0]->render('markdown_sample.tx')  };

builder {
    enable 'Plack::Middleware::Static',
        path => qr{^(?:/static/|/robot\.txt$|/favicon\.ico$)},
        root => File::Spec->catdir(dirname(__FILE__));
    enable 'Plack::Middleware::ReverseProxy';
    enable 'Plack::Middleware::Session';

    __PACKAGE__->to_app();
};

__DATA__
@@ markdown_sample.tx
<!doctype html>
<html>
<body>

<pre>
[% FILTER markdown %]
    [% INCLUDE 'docs.txt' %]
[% END %]
</pre>

</body>
</html>

@@ docs.txt
text