December 2011 Archives

Perldoc and I Would Like to Wish You a...

perldoc perlsyn | perl -ne 's/^.*?"|\\.*$//g,print if/1\.\.15/'

Alternative Dancer Templating Engines

Dancer uses a simple model of interfacing with templating engines (based on Dancer::Template::Abstract) and makes it very easy to add support for new engines. Thanks to this, if you're not happy with the default simple engine or with Template Toolkit, there is now a dozen different alternatives to choose from. Let's take a look at some of them.

Serving Files with Dancer::Plugin::DirectoryView and Dancer::Plugin::Auth::Htpasswd

A while ago I was converting a simple PHP website to Dancer, and moving it from being deployed on Apache to Starman. There wasn't a lot of code, so rewriting went quickly -- but, the site used a few specific features of Apache, namely directory indexes (courtesy of mod_autoindex) to allow user access to directories/files on the server, and htpasswd files to password-protect some of those directories.

I could just deploy the new Dancer website on Apache and keep using those goodies, but I thought that it would be nice if Dancer itself provided similar features. So, I created two plugins that do just that: Dancer::Plugin::DirectoryView and Dancer::Plugin::Auth::Htpasswd. Let me now show you how to use them.

About Michał Wojciechowski

user-pic I blog about Perl.