elife/patterns

eLife patterns

Installs: 13 075

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 8

Forks: 5

pkg:composer/elife/patterns

dev-master 2026-02-18 09:37 UTC

This package is auto-updated.

Last update: 2026-02-18 09:37:43 UTC


README

Build Status

PHP wrapper for eLife pattern library. The pattern library lives in ./patterns.

Development workflow

  • Make changes in the ./patterns, use local Makefile to make process easier.
  • Use top level Makefile to update php wrapper.
    • make update-local-patterns
    • make update-patterns Deprecated target, that was used when patterns where developed in a separate repository.
  • Use top level Makefile to assist php development.

Dependencies

Installation

Execute composer require elife/patterns:dev-master.

Running Tests

To run all tests:

make test

To run one test:

vendor/bin/phpunit tests/src/ViewModel/ArticleSectionTest.php

Versioning

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.

Usage

Create ViewModels 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));

Updating the library

  1. Install Docker.
  2. Execute bin/update to update the resources folder from Pattern Lab (you can pass a commit or pull request if needed, eg bin/update 4303c0199112724bd5725537c7192828099018fb or bin/update pr-850).
  3. Make changes to the view models accordingly.