PerlDancer / PerlDancer/Dancer2

Document how write a Dancer2 CGI app

Open
#1,679 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Beginner Suitable Documentation
Dominant language
Perl
Stars
604
Forks
288
Avg merge
1d 5h
Merged PRs (30d)
5

Description

I worked with @xsawyerx today and we figured out how to write a Dancer2 app in CGI. We feel like it should be documented but we're not sure where:

use Dancer2;
use Plack::Loader;
use Template::Provider::FromDATA;

# Tell Dancer to use the DATA section for templates                                                                                                                                                                                                                                                                                                                                                     
my $provider = Template::Provider::FromDATA->new( { CLASSES => __PACKAGE__ } );
set engines => {template => { template_toolkit => { LOAD_TEMPLATES => [ $provider ] }}};
set template => 'template_toolkit';

get '/' => sub {
    template 'mytemplate' => { bar => "foo" };
};
Plack::Loader->auto->run(main->to_app);

__DATA__                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                        
__mytemplate.tt__                                                                                                                                                                                                                                                                                                                                                                                       
Flib [% bar %]                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                        
__anothertemplate.tt__                                                                                                                                                                                                                                                                                                                                                                                  
Something else here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CGI application example in the issue and inspect the repository's existing documentation structure to find the appropriate location. Document the demonstrated Dancer2 CGI setup, including the embedded templates, so a reader can follow it as a complete example.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.