Download the PHP package balint777/twig-lambda without Composer

On this page you can find all versions of the php package balint777/twig-lambda. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twig-lambda

Twig Lambda

Lambda expressions for Twig and filters that make use of them


Quick examples

Listing names of all authors ordered by age:

Counting elements starting from specified letter:


Installation

Install via Composer:

Add the extension to Twig:

... or if you use Symfony, add the following to your services.yml config file:


Usage

Lambda expression

To create lambda expression prepend any valid Twig expression with => operator. Inside of the lambda expression you can use any variable from the outside. There are also two special variables available:

To create lambda expression with list of arguments, add it before => operator. Separate multiple arguments with semicolons. You can use brackets for readability.

Note that if you use list of arguments, _ variable is not longer available.


Below is a list of available filters and tests. All works with arrays and any Traversable object and preserve it keys. All lambdas are called with two arguments: element and key.


|map

Alias: |select
Signature: array|map(lambda)

Applies a given function to each element and returns array of results in the same order.


|filter

Alias: |where
Signature: array|filter(lambda)

Returns array of elements that passes a test specified by lambda.


|unique_by

Signature: array|unique_by(lambda|'==='|'==')

Returns array of unique elements. Uniqueness is checked with passed lambda. PHP operators == or === will be used if string '==' or '===' is passed instead of lambda.

Lambda should have two arguments - items to check. Keys of elements are also passed as third and fourth argument.

equivalent


|group_by

Signature: array|group_by(lambda)

Sorts an array into groups by the result of lambda.

will produce


|sort_by

Signature: array|sort_by(lambda[, direction = 'ASC'])

Sorts array by values returned by lambda. Direction can be 'ASC' or 'DESC'.


|count_by

Signature: array|count_by(lambda)

Sorts an array into groups and returns a count for the number of objects in each group.

If lambda returns true, false or null, it will be converted to string 'true', 'false' or 'null'. Float will be converted to integer.

will produce


is any

Signature: array is any(lambda)

Returns true if lambda returns true for any element from an array.

Returns false if array is empty.


is every

Signature: array is every(lambda)

Returns true if lambda returns true for every element from an array.

Returns true if array is empty.


call()

Signature: call(lambda [, arguments:array])

Calls lambda and returns its result. You can provide array of arguments.

This function is provided to allow creating twig macros taking lambda as an argument.


All versions of twig-lambda with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
twig/twig Version ^1.0 || ^2.0 || ^3.0
dpolac/dictionary Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package balint777/twig-lambda contains the following files

Loading the files please wait ....