[dancer-users] Do DSL words need a Plugin?

Henk van Oers hvo.pm at xs4all.nl
Sun Sep 20 15:48:41 BST 2015


A ::Plugin needs 2 name spaces Dancer:: and Dancer2::

But what about this construct:

---------------------
package MyApp::DSL;

# ABSTRACT: Just some syntax sugar for MyApp

use strict;
use warnings;
use Exporter qw(import);

our $VERSION = '0.01'; # VERSION

our @EXPORT_OK = qw(
     request_accept_language
);

our $twist = 2; # or 1;

BEGIN {
     $twist = (defined $INC{'Dancer2.pm'}) ? 2 : 1;
}

use if $twist == 2 , 'Dancer2';
use if $twist == 1 , 'Dancer' => ':syntax';

sub request_accept_language {
     return request->accept_language;
}

1;
---------------------

This one does not need any config
and maybe all common words can be in some common ::Sugar

NB: Next related post is about Plugins with some config.

-- 
Henk


More information about the dancer-users mailing list