modularr/yaml-front-matter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

modularr/yaml-front-matter

最新稳定版本:1.0.0

Composer 安装命令:

composer require modularr/yaml-front-matter

包简介

YAML-FrontMatter is a simple to use PHP-only FrontMatter type parser Library.

README 文档

README

Latest Version Software License Build Status Total Downloads

An easy to use class for handling YAML frontmatter in PHP.

What does this class do?

This class is a PHP implementation of Jekyll Front Matter.

Any file that contains a YAML front matter block will be processed as a special file. The front matter must be the first thing in the file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:

---
layout: post
title: Blogging Like a Hacker
---

Between these triple-dashed lines, you can set variables using YAML. You can access them via the fetch function. Conversion to Markdown is optional.

How to use

$page = new \Modularr\YAMLFrontmatter\FrontMatter('content/example.md');

echo '<h1><a href="'.$page->fetch('uri').'">'.$page->fetch('title').'</a></h1>
'.$page->fetch('content');

foreach($page->fetch('list') as $key => $value) {
    echo '<li>'.$key.' => '.$value.'</li>';
}
$array = $page->fetch('list');
echo $array['foo'];
---
foo: bar
title: Test
info: you can have as many custom fields as you like
date: 2005-09-16 17:20:42+00:00
layout: post
comments: true
slug: testing
list: { foo: bar, bar: baz }
list2:
- foo
- bar
list3:
    foo: bar
    bar: baz
---
<h1>Text Here</h1>
<p>content</p>

Installation

Install in via Composer:

composer require modularr/yaml-front-matter

If you are using the package in a VanillaJS project make sure you have:

require_once 'vendor/autoload.php';

统计信息

  • 总下载量: 567
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 37
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-27