New app created with  dancer -a YoApp

With config

template: "template_toolkit" engines: template_toolkit: PLUGIN_BASE: 'Template::Plugin' start_tag: '<%' end_tag: '%>'

New test filte that started out as an app:) YoApp/bin/filtertest.pl

#!/usr/bin/perl -- BEGIN{ $INC{'Template/Plugin/FilterFence.pm'}=__FILE__; package Template::Plugin::FilterFence; use Template::Plugin::Filter; use base qw( Template::Plugin::Filter ); sub filter { my ($self, $text) = @_; return join '&nbsp;', split '', $text ; } sub init { my $self = shift; $self->install_filter('fence'); return $self } 1; }; use Dancer; use YoApp; package YoApp; use Dancer ':syntax'; get '/filtertest' => sub { #~ template 'filtertest'; Dancer::Template->engine->render( \q{ <% USE FilterFence %> bird is "<% "bird" | $FilterFence %>" the word "<% "word" | fence %>" } ); }; #~ dance; exit; ## if you want to view in browser package main; use Dancer::Test; response_status_is [GET => '/filtertest'], 200, "GET /filtertest is fo +und"; response_content_like [GET => '/filtertest'], qr/something/, "somethin +g"; response_content_like [GET => '/filtertest'], qr/something/, "somethin +g"; Test::More::done_testing();

In reply to Re^2: Testing Custom Template Filters in Dancer (in-memory template) by Anonymous Monk
in thread Testing Custom Template Filters in Dancer by choroba

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.