elife / patterns
eLife patterns
dev-master
2024-12-12 13:17 UTC
Requires
- php: ^7.1 || ^8.0
- beberlei/assert: ^2.0
- mustache/mustache: ^2.5
Requires (Dev)
- justinrainbow/json-schema: ^5.1
- php-jsonpointer/php-jsonpointer: ^1.0
- phpspec/prophecy: ^1.10
- phpunit/phpunit: ^5.2
- squizlabs/php_codesniffer: ^3.5
- symfony/filesystem: ^3.0
- symfony/finder: ^3.0
- symfony/process: ^3.0
- symfony/yaml: ^3.1
- twig/twig: ^2.10
Suggests
- twig/twig: ^2.0, to use PatternExtension
- dev-master
- dev-updating-patterns-elife-logo-issue
- dev-spike/php-cs-fixer
- dev-new-term-pattern
- dev-refactor-not-yet-revised-to-not-revised
- dev-update_pattern_library/788
- dev-homepage-listing-changes
- dev-elife-assessment-move
- dev-update_pattern_library/785
- dev-update_pattern_library/784
- dev-previous-version-warning
- dev-update_pattern_library/782
- dev-update_pattern_library/779
- dev-update_pattern_library/772
- dev-update_pattern_library/771
- dev-cookiebot-auto-blocking
- dev-latest-changes
- dev-test-component
- dev-update_pattern_library/736
- dev-feature/highlight-item
- dev-update_pattern_library/715
- dev-update_pattern_library/696
- dev-update_pattern_library/693
- dev-update_pattern_library/690
- dev-update_pattern_library/688
- dev-update_pattern_library/684
- dev-update_pattern_library/683
- dev-update_pattern_library/685
- dev-update_pattern_library/682
- dev-update_pattern_library/681
- dev-update_pattern_library/680
- dev-content-header-new
- dev-update_pattern_library/679
- dev-update_pattern_library/678
- dev-button-collection-inline
- dev-update_pattern_library/677
- dev-update_pattern_library/676
- dev-action-buttons
- dev-update_pattern_library/674
- dev-update_pattern_library/673
- dev-update_pattern_library/669
- dev-fix-tests-on-journal
- dev-update_pattern_library/664
- dev-update_pattern_library/663
- dev-update_pattern_library/662
- dev-update_pattern_library/661
- dev-update_pattern_library/646
- dev-teaser-meta-status-and-date
- dev-update_pattern_library/642
- dev-update_pattern_library/641
- dev-update_pattern_library/640
- dev-include_status_in_item_listed
- dev-add_curation_labels_in_item_listed_and_article_pages
- dev-long-url-issues-ongoing
- dev-staging
- dev-Include_date_in_item_listed
- dev-line-break-issues
- dev-feature/hero-banner
- dev-content-header-magazine-articles
- dev-author-list
- dev-readcube-check
- dev-reference-title-popup
- dev-pattern-library-node-test
- dev-add-css-grid-framework
- dev-update_pattern_library/613
- dev-update_pattern_library/612
- dev-content-headers
- dev-button-text-followup
- dev-navigation-changes
- dev-non-doi-link-styling
- dev-new-reference-styling
- dev-fragment-handler-fix
- dev-see-all-link-additional-assets
- dev-image-attribution-addition
- dev-covers-logo-url
This package is auto-updated.
Last update: 2024-12-12 13:17:50 UTC
README
This library provides a PHP implementation for the Mustache templates/assets produced by the eLife Sciences Pattern Library.
Dependencies
- Composer
- PHP 7
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 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));
Updating the library
- 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.