jmf/twig-extensions-bundle
最新稳定版本:1.0.0
Composer 安装命令:
composer require jmf/twig-extensions-bundle
包简介
Collection of Twig extensions as a Symfony Bundle
README 文档
README
Collection of Twig extensions as a Symfony Bundle, which provides:
- array operations;
- set/unset a specific array key (
array_set,array_unset) - add a value to front/back of array (
array_push,array_unshift) - remove a value from front/back of array (
array_pop,array_shift)
- set/unset a specific array key (
- currency operations:
- format a money amount (
amount|money_amount)
- format a money amount (
- inlining operations:
- dump the raw content of a file (
inline('style.css'))
- dump the raw content of a file (
- sorting operations:
- sort arrays by value (
sort,rsort) - sort arrays by value, keeping associativity (
asort,arsort) - sort arrays by key (
ksort,krsort) - sort arrays by properties (
psort)
- sort arrays by value (
- time-related operations:
- adds direct access to PHP microtime() function
- adds direct access to PHP intl_format() function
- type-related operations:
- adds direct access to PHP get_class() and gettype() functions
- adds support to identify a Twig variable type with new tests (
is array,is string, etc)
Installation & Requirements
Install with Composer:
composer require jmf/twig-extensions-bundle
If you have Flex installed, the Twig extensions are then instantly available without any need for initial configuration.
If not, complete your config/bundles.php file as indicated below:
<?php return [ // ... // Other existing bundles. // ... Jmf\TwigExtensionsBundle\JmfTwigExtensionsBundle::class => ['all' => true], ];
Configuration (optional)
Either run the following command:
bin/console config:dump jmf_twig_extensions > config/packages/jmf_twig_extensions.yaml
Or create a jmf_twig_extensions.yaml file in the config/package directory as follows:
jmf_twig_extensions: # Twig "array" extension configuration. array: enabled: true # Optional prefix before function and filter names. prefix: '' # Twig "currency" extension configuration. currency: enabled: true # Optional prefix before function and filter names. prefix: '' # Twig "inline" extension configuration. inline: # Base path to restrict file inlining. Also, all calls to the "inline" function will be relative to this path. basePath: '%kernel.project_dir%/templates' enabled: true # Optional prefix before function and filter names. prefix: '' # Twig "sort" extension configuration. sort: enabled: true # Optional prefix before function and filter names. prefix: '' # Twig "time" extension configuration. time: enabled: true # Optional locale for date and time representation. locale: null # Optional prefix before function and filter names. prefix: '' # Twig "type" extension configuration. type: enabled: true # Optional prefix before function and filter names. prefix: ''
You may then alter any parameter to fit your needs.
Included Twig Extensions
Twig array extension
See https://packagist.org/packages/jmf/twig-array for documentation.
Twig currency extension
See https://packagist.org/packages/jmf/twig-currency for documentation.
Twig inline extension
See https://packagist.org/packages/jmf/twig-inline for documentation.
Twig sort extension
See https://packagist.org/packages/jmf/twig-sort for documentation.
Twig time extension
See https://packagist.org/packages/jmf/twig-time for documentation.
Twig type extension
See https://packagist.org/packages/jmf/twig-type for documentation.
统计信息
- 总下载量: 114
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2025-04-05