Mason:...:Setup(3pm)

πŸ“¦
version 2.24 Β· 2 versions
  • 2.24 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.24 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Mason:...:Setup(3pm) β€” like, the setup manual bestie πŸ’–

User Contributed Perl Documentation ✨ okay so this is Mason::Manual::Setup, and it's literally just called Setting up Mason. Buckle up, we're installing vibes.


🌸 NAME 🌸

Mason::Manual::Setup β€” setting up Mason πŸŽ€


✨ SETUP ✨

πŸ¦‹ Web development πŸ¦‹

The most common use of Mason is to generate dynamic web content, and honestly? That's its whole main character moment.

Poet is a web framework designed specifically to work with Mason. Given an HTTP request, Poet generates a corresponding Mason request, and uses the output from Mason to form the HTTP response. Poet takes care of the web development details that are outside of Mason's domain β€” stuff like server integration and configuration. Poet::Manual::Tutorial shows how to set up a Poet/Mason site in great detail, so go read that if you want the full step-by-step.

Mason can also be used in the popular web frameworks Catalyst and Dancer, as a drop-in replacement for their default template engines. See Catalyst::View::Mason2 and Dancer::Template::Mason2. Slay πŸ’…

🧚 Non-web development 🧚

Mason can be used to generate any kind of dynamic content, not just websites. The author has personally used it to generate Apache configuration files, emails, and C++ code. Yes bestie, C++ code. Range.

To use Mason from a script or library, use the Mason::Interp API:

my $interp = Mason->new(
    comp_root => '/path/to/comps',
    data_dir  => '/path/to/data',
    ...
);
my $output = $interp->run( '/request/path', foo => 5 )->output();

If you want to process a directory with a mix of Mason templates and static files, check out Any::Template::ProcessDir. It's giving exactly what you need 🫢

Wanna try out Mason syntax straight from the command line? Use the mason script:

% mason
2 + 2 = <% 2+2 %>
^D
2 + 2 = 4

Not me casually getting 4 back 😭 iconic behaviour fr fr.


πŸ’œ LOGGING πŸ’œ

Mason uses Log::Any to log various events, such as the start and end of each request. You can direct these logs to the output of your choice β€” see Log::Any::Adapter. If you don't specify anything, then the logs will go into the void. πŸ•³οΈ Just gone. No thoughts, head empty.


⭐ SEE ALSO ⭐

  • Mason

πŸ‘‘ AUTHOR πŸ‘‘

Jonathan Swartz <swartz@pobox.com>


This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


That's the whole page bestie β€” brought to you by perl v5.34.0, dated 2022-05-27, under the Mason:...:Setup(3pm) banner from the User Contributed Perl Documentation crew. Go set something up, you've got this πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from