Recipe(3pm)

πŸ“¦
version 2.5.0 Β· 2 versions
, in ubuntu jammy

πŸ’– Recipe(3pm) β€” Embperl::Recipe πŸ’–

okay bestie, welcome to Embperl::Recipe, aka the base class for defining custom recipes. yes, this is the Recipe(3pm) page. yes it's a perl module. yes it's giving elite plumbing. let's get into it 🫢


✨ SYNOPSIS ✨

EMBPERL_RECIPE "XSLT Embperl"

🌸 DESCRIPTION 🌸

So like. Embperl::Recipe hands you the basic features you need to build your own recipes. That's the whole vibe. To do it, you make a class that has a get_recipe method, and that method returns an array reference describing what to do. That's it, that's the assignment. πŸ’…

πŸ¦‹ get_recipe ($class, $r, $recipe) πŸ¦‹

  • $class β€” the class name, iconic, mysterious, just vibing
  • $r β€” the Embperl request record object (Embperl::Req), and it might be a derived object when you're running under EmbperlObject. so like, don't assume, check
  • $recipe β€” the name of the recipe

The function must return an array that describes the desired action. That array contains a tree structure of providers. yes. a tree. of providers. we love a nested moment 🌳✨

πŸŽ€ Providers πŸŽ€

file

read file data πŸ“„

Parameter:

  • filename β€” gives the file to read

memory

get data from a scalar 🧠

Parameter:

  • source β€” gives the source as a scalar reference
  • name β€” gives the name under which this item should be cache

epparse

parse file into a Embperl tree structure 🌲

Parameter:

  • source β€” gives the source
  • syntax β€” syntax to use

epcompile

compile Embperl tree structure βš™οΈ

Parameter:

  • source β€” gives the source

eprun

execute Embperl tree structure πŸƒβ™€οΈ

Parameter:

  • source β€” gives the source
  • cache_key β€” see description of cacheing
  • cache_key_options β€” see description of cacheing
  • cache_key_func β€” see description of cacheing

eptostring

convert Embperl tree structure to string πŸ”€

Parameter:

  • source β€” gives the source

libxslt-parse-xml

parse xml source for libxslt πŸ“₯

Parameter:

  • source β€” gives the xml source

libxslt-compile-xsl

parse and compile stylesheet for libxslt 🧡

Parameter:

  • stylesheet β€” gives the stylesheet source

libxslt

do a xsl transformation via libxslt πŸ”₯

Parameter:

  • source β€” gives the parsed xml source
  • stylesheet β€” gives the compiled stylesheet source
  • param β€” gives the parameters as hash ref

xalan-parse-xml

parse xml source for xalan πŸ“₯

Parameter:

  • source β€” gives the xml source

xalan-compile-xsl

parse and compile stylesheet for xalan 🧡

Parameter:

  • stylesheet β€” gives the stylesheet source

xalan

do a xsl transformation via xalan πŸ”₯

Parameter:

  • source β€” gives the parsed xml source
  • stylesheet β€” gives the compiled stylesheet source
  • param β€” gives the parameters as hash ref

πŸ’œ Cache parameter πŸ’œ

the whole squad, no explanations, just names, iykyk:

  • expires_in
  • expires_func
  • expires_filename
  • cache

⭐ Format ⭐

Heres an example that show how the recipe must be build: πŸ‘‘

  sub get_recipe

    {
    my ($class, $r, $recipe) = @_ ;

    my $param  = $r -> component -> param  ;
    my @recipe ;

    push @recipe, {'type'   =>  'file'      } ;
    push @recipe, {'type'   =>  'epparse'   } ;
    push @recipe, {'type'   =>  'epcompile', cache => 1 } ;
    push @recipe, {'type'   =>  'eprun'     }  ;

    my $config = $r -> component -> config  ;
    my $xsltproc = $config -> xsltproc ;

    my @stylesheet =
        (
        { type => 'file',  filename  => $config -> xsltstylesheet, },
        { type =>  $xsltproc . '-compile-xsl', cache => 1 },
        ) ;

    push @recipe, {'type'   =>  'eptostring' } ;
    push @recipe, {'type'   =>  $xsltproc . '-parse-xml', } ;
    push @recipe, {'type'   =>  $xsltproc,   stylesheet => \@stylesheet } ;

    return \@recipe ;
    }

This corresponds to the following diagramm (when xsltproc = xalan):

    +-------------------+   +--------------------+
    + file {inputfile}  +   +file{xsltstylesheet}+
    +-------------------+   +--------------------+
          |                         |
          v                         v
    +-------------------+   +-------------------+
    + xalan-parse-xml   +   + xalan-compile-xsl +
    +-------------------+   +-------------------+
          |                         |
          |                         |
          |         +-----------+   |
          +-------> + xalan     + <-+
                    +-----------+
lowkey the realest advice on this whole page: take a look at the recipes that comes with Embperl to get more ideas what can be done. fr fr, the source is the syllabus πŸ“šβœ¨

okay that's the whole page, bestie, you ate it πŸ’… this lil' classic came to you from perl v5.34.0, dated 2022-02-06, and yeah it's filed under Recipe(3pm) in the User Contributed Perl Documentation. no cap, go build something iconic πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from