Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Testing Custom Template Filters in Dancer (in-memory template)

by Anonymous Monk
on Feb 05, 2015 at 23:07 UTC ( [id://1115709]=note: print w/replies, xml ) Need Help??


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 '&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();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1115709]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found