creativeservices / fixtures
Use fixture content in Twig templates
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/creativeservices/fixtures
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
They can be used to populate templates during development. They can also serve as content sources for static site generators and style guides.
Supported formats
- JSON
- YAML
- Markdown
Usage
Create a fixture collection from a directory of fixture files:
$fixtures = FixtureCollection::fromDirectory('/path/to/fixture/files');
Get a piece of content from the collection:
$context = $fixtures['fixture-file.json'];
When the Twig extension is enabled, fixture content is available inside templates with the _fixture
function:
{% set article = _fixture('article.json') %}
{{ article.title }}