Skip to content

Twig functions that return a package version by using PackageVersions library

License

Notifications You must be signed in to change notification settings

emodric/twig-package-versions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package Versions Twig extension

Build Status Downloads Latest stable License

This package provides simple Twig functions that wrap PackageVersions lib by Marco Pivetta and PrettyPackageVersions lib by Alessandro Lai making it possible to output version strings of your libraries directly inside your Twig templates.

Initially, this Twig extension was submitted as a pull request against official Twig Extensions collection, but was turned into a separate package since no new features are accepted over there.

Installation

To install this extension, use Composer:

composer require emodric/twig-package-versions

Using the extension

In PHP:

$twig = new \Twig\Environment($loader, $options);

$twig->addExtension(new \EdiModric\Twig\VersionExtension());

In a Symfony project, you can register the extension as a service:

services:
    twig.extension.version:
        class: EdiModric\Twig\VersionExtension
        tags:
            - { name: twig.extension }

Once set up, you can use the following Twig functions:

  • package_version('my-vendor/package-name') - Returns the package version string as returned by PackageVersions\Versions::getVersion method
  • pretty_package_version('my-vendor/package-name') - Returns the Jean85\Version object as returned by Jean85\PrettyVersions::getVersion method

About

Twig functions that return a package version by using PackageVersions library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages