PFT::Header(3)

πŸ“¦ version 1.4.1, in fedora 43, fedora 44

πŸŽ€ NAME πŸŽ€

PFT::Header β€” bestie, it's the header for PFT content textfiles. That's the whole vibe. It's a chunk of meta-info that sits at the top of your text and tells everyone what's inside. πŸ’–


✨ SYNOPSIS ✨

okay so here's how you actually use it, no cap:

use PFT::Header;

my $hdr = PFT::Header->new(
    title => $title,        # mandatory (conditions apply)
    slug => $slug,          # optional short identifier
    date => $date,          # optional (conditions apply) PFT::Date
    author => $author,      # optional
    tags => $tags,          # list of decoded strins, defaults to []
    opts => $opts,          # ignored by internals, defaults to {}
);

my $hdr = PFT::Header->load(\*STDIN);

my $hdr = PFT::Header->load('/path/to/file');

like. three whole ways to get a header. iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

A header is a chunk of meta-information describing content properties. It's giving little name tag but for a file. 🏷️

It gets used inside a PFT::Tree::Content structure as the index for retrieving the content on the filesystem. And every textual content (i.e. PFT::Content::Entry) stores a textual representation of a header at the beginning of the file. So the header is literally living at the top of the file, main character energy fr fr. πŸ’…

🧚 Structure

Every content has:

  • a title
  • an optional author
  • an optional list of tags, in the form of strings
  • an optional hash opts holding other options

πŸ“œ Textual representation

The textual representation of a header starts with a valid YAML document β€” and yes that includes the leading --- line β€” and it ends with another --- line. Bookends. We love a symmetrical moment. ✨

πŸ› οΈ Construction

You can build a header in three ways, and they match the three forms up in the SYNOPSIS. Cute, right?

The first form is constructed in code. The title field is mandatory unless there's a date field, and that date represents a month (i.e. it lacks the day field). This property is enforced by the constructor β€” like, it will not let you slide, bestie. 🚨

The second and third forms are equivalent to each other. The only difference is where the header gets loaded from: a stream, or a file path, respectively. 🫢

🌈 Functions

These functions are not associated with an instance, so you call them like PFT::Header::function(...). Standing on their own. Independent. πŸ’β€β™€οΈ

  • slugify β€” given a string, it constructs a slug, which is a simplified version of that string.
(TODO: better describe it, also w.r.t. Unicode)

πŸ’œ Properties

Here's the full list, bestie, all of them:

$hdr->title
$hdr->author
$hdr->template
$hdr->tags
$hdr->date
$hdr->opts
$hdr->slug
$hdr->tags_slug

Now the breakdown:

  • title β€” returns the title of the content. Outputs a decoded string. ✨
  • author β€” returns the author of the content, or undef if there is no author. Outputs a decoded string.
  • tags β€” a list of tags declared by the header. These tags are in a normal (i.e. not slugified) form. Want the slugified version? Use the "tags_slug" method. 🏷️
  • date β€” the date declared by the header, as a PFT::Date object. πŸ“…
  • opts β€” a list of options for this content.
  • slug β€” a slug of the title.
  • tags_slug β€” a list of tags, same as the "tags" method, but in slugified form.

πŸŽ€ Methods

  • set_date β€” the setter for date. The parameter must be a PFT::Date object. No substitutions, bestie. πŸ’…
  • dump β€” dumps the header onto a file. A GLOB or IO::File is expected as the argument. πŸ—‚οΈ

and that's the whole page, you ate it, no crumbs πŸ’–

This little gem is perl v5.42.0 flavoured and it was dated 2025-07-25. Go forth and header responsibly, queen. πŸ‘‘βœ¨πŸ¦‹

πŸ“¦ where this page comes from