"Bolt Utility Box" contains various utility methods for Bolt CMS. Current twig functions:
{{md5('string')}}
Converts the given string to an MD5 hash.
Argument | Required | Default | Description |
---|---|---|---|
string | Yes | N/A | The string to turn into a hash. |
{% set array = [{ 'id': 1, 'name': 'bob'}, { 'id': 2, 'name': 'joe'}, { 'id': 3, 'name': 'kelly'}] %}
{% set removed = remove_record(array, [2]) %}
{{dump(removed)}}
Removes the ids in arrayIds from the given array of objects.
Argument | Required | Default | Description |
---|---|---|---|
array | Yes | N/A | The array of objects to filter. |
remove_id_array | Yes | N/A | An array of id's to remove from the array. |
{% set array = [{ 'id': 1, 'name': 'bob'}, { 'id': 2, 'name': 'joe'}, { 'id': 3, 'name': 'kelly'}] %}
{% set sorted = sort_obj_array(array, 'name', 'asc') %}
{{dump(sorted)}}
Sorts an object array by the given key's value.
Argument | Required | Default | Description |
---|---|---|---|
array | Yes | N/A | The array of objects to sort. |
key | Yes | N/A | The object's key to sort by. |
direction | No | asc | Direction to sort with. (asc = Ascending, desc = Descending) |
This repository is following the branching technique described in this blog post, and the semantic version set out on the Semantic Versioning Website. We also follow FIG Standard for writing code.
To lint your code, run:
composer run lint
To run the tests, run:
composer run test
This script is created by Missional Digerati and is under the GNU General Public License v3.