# lib/Blog/View/TD/Main.pm package Blog::View::TD::Main; use strict; use warnings; use Template::Declare::Tags; sub wrapper(&) { my $content = shift; smart_tag_wrapper { html { head { title { c->stash->{title}; }; }; body { h1 { c->stash->{title} }; $content->(); } } } } template all_posts => sub { c->stash->{title} = 'Blog posts'; wrapper { foreach my $post (@{c->stash->posts||[]}) { div { attr { class => 'post' }; h2 { $post->title }; p { 'Written by ' . $post->author}; }; div { attr { class => 'body'}; outs_raw($post->body); # bad } } } }; 1; __END__