This library provides a PHP implementation for the Mustache templates/assets produced by the eLife Sciences Pattern Library.
- Composer
- PHP 7
Execute composer require elife/patterns:dev-master
.
This library is not versioned as the eLife Patterns can make breaking changes at any time. It's not expected to be used by libraries, but by applications where Composer lock files are used. These tie the application to a specific commit.
Create ViewModel
s and pass them to a PatternRenderer
, which will return the rendered template.
For example:
use eLife\Patterns\PatternRenderer\MustachePatternRenderer;
$helpers = [
'assetsPath' => '/path/to/assets',
'assetRewrite' => function (string $path, Mustache_LambdaHelper $helper) : string {
return $helper->render($path).'?cache-buster';
},
];
$mustache = new Mustache_Engine([
'helpers' => $helpers,
'loader' => new Mustache_Loader_FilesystemLoader('/path/to/patterns-php'),
]);
$patternRenderer = new MustachePatternRenderer($mustache);
var_dump($patternRenderer->render($viewModel));
- Install Docker.
- Execute
bin/update
to update theresources
folder from Pattern Lab (you can pass a commit or pull request if needed, egbin/update 4303c0199112724bd5725537c7192828099018fb
orbin/update pr-850
). - Make changes to the view models accordingly.