Skip to content

Commit

Permalink
process Blog tag text as Markdown
Browse files Browse the repository at this point in the history
It's much nicer to be able to introduce a tag with some rich Markdown or
HTML. This also fixes the spurious `<p>` tag if we happened to use
Markdown in our tag text.

Fixes #397
  • Loading branch information
preaction committed Oct 16, 2015
1 parent 1e635e6 commit 9ba3046
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion share/theme/bootstrap/blog/index.html.ep
Expand Up @@ -5,7 +5,7 @@
<main>

% if ( my $tag_text = $self->data->{ tag_text } ) {
<p><%= $tag_text %></p>
<%= markdown $tag_text %>
% }

% for my $page ( @$pages ) {
Expand Down
2 changes: 1 addition & 1 deletion share/theme/default/blog/index.html.ep
Expand Up @@ -5,7 +5,7 @@
<main>

% if ( my $tag_text = $self->data->{ tag_text } ) {
<p><%= $tag_text %></p>
<%= markdown $tag_text %>
% }

% for my $page ( @$pages ) {
Expand Down
24 changes: 24 additions & 0 deletions t/theme/check.t
Expand Up @@ -43,6 +43,13 @@ my @documents = (
my $blog = Statocles::App::Blog->new(
url_root => '/blog',
store => '.',
tag_text => {
foo => <<ENDMARKDOWN,
# Foo!
Bar, baz, and fuzz!
ENDMARKDOWN
},
);

my $site = Statocles::Site->new(
Expand Down Expand Up @@ -80,6 +87,9 @@ $page{ list } = Statocles::Page::List->new(
pages => [ $page{ document } ],
next => 'page-0.html',
prev => 'page-1.html',
data => {
tag_text => $blog->tag_text->{ foo },
},
);

$page{ feed } = Statocles::Page::List->new(
Expand Down Expand Up @@ -220,6 +230,20 @@ my %content_tests = (
};

},

'blog/index.html.ep' => sub {
my ( $content ) = @_;
my $dom = Mojo::DOM->new( $content );

subtest 'tag text exists and is processed as Markdown' => sub {
if ( ok my $h1 = $dom->at( 'main > h1' ), 'tag text h1 exists' ) {
is $h1->text, 'Foo!', 'h1 text is correct';
}
if ( ok my $p = $dom->at( 'main > p' ), 'tag text p exists' ) {
is $p->text, 'Bar, baz, and fuzz!', 'p text is correct';
}
};
},
);


Expand Down

0 comments on commit 9ba3046

Please sign in to comment.