creativeservices / fixtures
此包已被废弃且不再维护。未建议替代包。
在Twig模板中使用fixture内容
v1.0.0-beta1
2018-10-25 13:14 UTC
Requires
- php: >=7.0
- eloquent/pathogen: ^0.6.1
- erusev/parsedown: ^1.7
- symfony/yaml: ~2.7|3.*|^4.1
- twig/twig: ~1.20|~2.0
Requires (Dev)
- phpunit/phpunit: ~7.4
This package is auto-updated.
Last update: 2022-03-29 00:21:29 UTC
README
它们可以在开发过程中用于填充模板。它们还可以作为静态网站生成器和样式指南的内容来源。
支持的格式
- JSON
- YAML
- Markdown
使用方法
从fixture文件目录创建fixture集合
$fixtures = FixtureCollection::fromDirectory('/path/to/fixture/files');
从集合中获取内容片段
$context = $fixtures['fixture-file.json'];
当启用Twig扩展时,可以使用_fixture
函数在模板内访问fixture内容
{% set article = _fixture('article.json') %}
{{ article.title }}