From af2c92d9fe83268f159d2c1ed4b280e4a30c1253 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 9 Jun 2020 21:50:51 +0300 Subject: [PATCH] Twig 1.0.3 --- CHANGELOG.md | 7 ++- README.md | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++- plugin.yaml | 2 +- 3 files changed, 146 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9f576..a152260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ + +# [1.0.3](https://github.com/flextype-plugins/twig/compare/v1.0.2...v1.0.3) (2020-06-09) + +### Feature +* **core:** add ArrTwigExtension + # [1.0.2](https://github.com/flextype-plugins/twig/compare/v1.0.1...v1.0.2) (2020-05-07) ### Bug fixes * **core:** fix markdown filter - # [1.0.1](https://github.com/flextype-plugins/twig/compare/v1.0.0...v1.0.1) (2020-05-07) diff --git a/README.md b/README.md index 1d72906..971ca06 100755 --- a/README.md +++ b/README.md @@ -10,8 +10,6 @@ Twig plugin to present Twig template engine for Flextype. The following dependencies need to be installed for Twig Plugin. -### System - | Item | Version | Download | |---|---|---| | [flextype](https://github.com/flextype/flextype) | 0.9.8 | [download](https://github.com/flextype/flextype/releases) | @@ -338,6 +336,145 @@ Usage: {% do emitter.emitBatch({'onThemeHeader', 'onSomeOtherEvent'}) %} ``` +##### arr + +Contains methods that can be useful when working with arrays. + +Sorts a multi-dimensional array by a certain column + +Usage: + +```twig +{% set new_array = arr.sort(old.array, 'title') %} +``` + +Sets an array value using "dot notation". + +Usage: + +```twig +{% set entry = arr.set(entry, 'title', 'New Title') %} +``` + +Return value from array using "dot notation". +If the key does not exist in the array, the default value will be returned instead. + +Usage: + +```twig +{{ arr.get(entry, 'title') }} +``` + +Delete an array value using "dot notation". + +Usage: + +```twig +{% set entry = arr.delete(entry, 'title') %} +``` + +Checks if the given dot-notated key exists in the array. + +Usage: + +```twig +{% if arr.keyExists(entry, 'title') %} + Do something... +{% endif %} +``` + +Returns a random value from an array. + +Usage: + +```twig +{{ arr.random(['php', 'js', 'css', 'html']) }} +``` + +Returns TRUE if the array is associative and FALSE if not. + +Usage: + +```twig +{% if arr.isAssoc(entry) %} + Do something... +{% endif %} +``` + +Returns TRUE if the array is associative and FALSE if not. + +Usage: + +```twig +{% set array1 = {'name': 'john', 'mood': 'happy', 'food': 'bacon'} %} +{% set array2 = {'name': 'jack', 'food': 'tacos', 'drink': 'beer'} %} +{% set array3 = arr.overwrite(array1, array2) %} +``` + +Converts an array to a JSON string + +Usage: + +```twig +{{ arr.json(entry) }} +``` + +Returns the first element of an array + +Usage: + +```twig +{{ arr.first(entry) }} +``` + +Returns the last element of an array + +Usage: + +```twig +{{ arr.last(entry) }} +``` + +Converts an array to a JSON string + +Usage: + +```twig +{{ arr.toJson(entry) }} +``` + +Create an new Array from JSON string. + +Usage: + +```twig +{% set array = arr.createFromJson($string) %} +``` + +Create an new Array object via string. + +Usage: + +```twig +{% set array = arr.createFromString('cat, dog, bird', ',') %} +``` + +Counts all elements in an array. + +Usage: + +```twig +{{ arr.size(array) }} +``` + +Return an array with elements in reverse order. + +Usage: + +```twig +{% set new_array = arr.reverse(old_array) %} +``` + #### Global Variables ```twig diff --git a/plugin.yaml b/plugin.yaml index 5c086f6..c4ad3a4 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: Twig -version: 1.0.2 +version: 1.0.3 description: Twig plugin to present Twig template engine for Flextype. icon: fas fa-palette author: