yaml-front-matter

A to the point yaml front matter parser

  • 所有者: spatie/yaml-front-matter
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

yaml-front-matter

Latest Version on Packagist
Software License
Build Status
Quality Score
Total Downloads

A to the point front matter parser. Front matter is metadata written in yaml, located at the top of a file wrapped in ---'s.

---
title: Example
---

Lorem ipsum.
$object = YamlFrontMatter::parse(file_get_contents(__DIR__.'/example.md'));

$object->matter('title'); // => 'Example';
$object->body(); // => 'Lorem ipsum.'

// Or retrieve front matter with a property call...

$object->title; // => 'Example';

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Install

You can install the yaml-front-matter via composer:

$ composer require spatie/yaml-front-matter

Usage

Consider the example.md file from above. First you'll need to parse the contents:

$object = YamlFrontMatter::parse(file_get_contents('example.md'));

The parser will return a YamlFrontMatterObject, which can be queried for front matter or it's body.

$object->matter(); // => ['title' => 'Example']
$object->matter('title'); // => 'Example'
$object->body(); // => 'Lorem ipsum.'
$object->title; // => 'Example'

Protip: The matter function also accepts dot notation for nested fields, e.g. matter('meta.keywords').

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon.
All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.

概覽

名稱與所有者spatie/yaml-front-matter
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
發布數14
最新版本名稱2.0.8 (發布於 )
第一版名稱1.0.0 (發布於 )
創建於2016-01-13 21:26:46
推送於2023-12-04 10:03:30
最后一次提交
星數322
關注者數10
派生數28
提交數110
已啟用問題?
問題數0
打開的問題數0
拉請求數21
打開的拉請求數0
關閉的拉請求數5
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部