1PFT::Header(3)        User Contributed Perl Documentation       PFT::Header(3)
2
3
4

NAME

6       PFT::Header - Header for PFT content textfiles
7

SYNOPSIS

9           use PFT::Header;
10
11           my $hdr = PFT::Header->new(
12               title => $title,        # mandatory (conditions apply)
13               slug => $slug,          # optional short identifier
14               date => $date,          # optional (conditions apply) PFT::Date
15               author => $author,      # optional
16               tags => $tags,          # list of decoded strins, defaults to []
17               opts => $opts,          # ignored by internals, defaults to {}
18           );
19
20           my $hdr = PFT::Header->load(\*STDIN);
21
22           my $hdr = PFT::Header->load('/path/to/file');
23

DESCRIPTION

25       A header is a chunk of meta-information describing content properties.
26
27       It is used in a PFT::Tree::Content structure as index for retrieving
28       the content on the filesystem. Every textual content (i.e.
29       PFT::Content::Entry) stores a textual representation of an header in
30       the beginning of the file.
31
32   Structure
33       Each content has a title, an optional author, an optional list of tags
34       in form of strings, an optional hash opts containing other options.
35
36   Textual representation
37       The textual representation of a header starts with a valid YAML
38       document (including the leading '---' line and ends with another '---'
39       line).
40
41   Construction
42       The header can be constructed in three ways, corresponding to the three
43       forms in the SYNOPSIS.
44
45       The first form is constructed in code. The title field is mandatory
46       unless there is a date field, and the date represents a month (i.e.
47       lacks the day field). This property is enforced by the constructor.
48
49       The second and third forms are equivalent, and they differ in the
50       source from which a header is loaded (a stream or a file path,
51       respectively).
52
53   Functions
54       The following functions are not associated with an instance. Call them
55       as PFT::Header::function(...)
56
57       slugify
58           Given a string, construct a slug, that is a simplified version of
59           such string.
60
61           (TODO: better describe it, also w.r.t. Unicode)
62
63   Properties
64           $hdr->title
65           $hdr->author
66           $hdr->template
67           $hdr->tags
68           $hdr->date
69           $hdr->opts
70           $hdr->slug
71           $hdr->tags_slug
72
73       title
74           Returns the title of the content.
75
76           Outputs a in decoded string.
77
78       author
79           Returns the author of the content, or undef if there is no author.
80
81           Outputs a in decoded string.
82
83       tags
84           A list of tags declared by the header.
85
86           The tags are in a normal (i.e. not slugified) form. For a slugified
87           version use the "tags_slug" method.
88
89       date
90           The date declared by the heade, as PFT::Date object.
91
92       opts
93           A list of options for this content.
94
95       slug
96           A slug of the title.
97
98       tags_slug
99           A list of tags as for the "tags" method, but in slugified form.
100
101   Methods
102       set_date
103           Setter for date. The parameter must be a PFT::Date object.
104
105       dump
106           Dump the header on a file. A GLOB or IO::File is expected as
107           argument.
108
109
110
111perl v5.36.0                      2023-01-20                    PFT::Header(3)
Impressum