in reply to Re: Testing Custom Template Filters in Dancer
in thread Testing Custom Template Filters in Dancer
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 ' ', 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();
|
|---|