For those of you not wondering what Front Matter is you may skip to the next heading, for every one else I will provide a quick explanation:
Front Matter is a block of YAML formatted text sandwiched between triple-dashed lines (I did say it would be quick).
Front Matter provides the facility to set predefined variables or for you to set your own. The parsed YAML is made available as PHP variables to the page template and any layouts or includes that rely on the page.
For example, the below YAML block is accessible from within the page itself as the string
$title and array
$tags; it's also available to any collection that page belongs to and therefore can be used to filter a collection – more information on this can be found here.
--- title: Hello World! tags: - One - Two - Three ---
Tapestry has a small number of pre-defined variables that are programmatically set when a source file is parsed; also collections can be configured to inject pre-defined variables into their children; for example the blog collection sets the page's categories and tags to an empty array if none are defined in the file in question.
- date: This value is first set to the last modified timestamp of the file, Tapestry then checks to see if the filename contains a date in the format
YYYY-MM-DD-filename.extand setting the value to that if found before lastly checking the files front matter and setting the date if found from there.
- title: This value is first set to the filename of the file, if the filename contains hyphens those are converted to spaces; Tapestry also parses out any date in the YYYY-MM-DD format. Tapestry then sets this value to what is defined in the files front matter, if set.
- layout: This value is set to an empty string if not set within the files front matter.