Releases: CarbonPackages/Carbon.Eel
1.12.0
✨ Features
Carbon.String.merge(mixed1, mixed2, mixedN)
Merge strings and arrays to a string with unique values, separated by an empty space.
Examples:
Expression | Result |
---|---|
Carbon.String.merge('', 'one') |
'one' |
Carbon.String.merge(['one two three'], ['one', 'four']) |
'one two three four' |
Carbon.String.merge(null, null) |
null |
Carbon.String.merge('one two three', ['one', 'four'] |
'one two three four' |
Return The merged string
Carbon.Array.check(variable)
Check if a variable is iterable and has items
Return The variable or null
if it is empty or not an iterable
Carbon.Array.intersect(firstArray, secondArray)
Returns an array containing all the values of firstArray
that are present in all the arguments.
Carbon.Array.length(array)
The method counts elements of a given array or a countable object. Return 0
if it is not an countable object.
count = ${Carbon.Array.length(countable)}
Carbon.Array.hasKey(array, key)
Returns a boolean if the array has a specific key
bool = ${Carbon.Array.hasKey(array, key)}
Carbon.Array.hasValue(array, value)
Returns a boolean if the array has a specific value
bool = ${Carbon.Array.hasValue(array, value)}
Carbon.Array.getValueByPath(array, path)
Returns the value of a nested array by following the specified path.
value = ${Carbon.Array.getValueByPath(array, path)}
Carbon.Array.setValueByPath(array, path)
Sets the given value in a nested array or object by following the specified path.
array = ${Carbon.Array.setValueByPath(subject, path, value)}
Carbon.Date.secondsUntil(string)
Return seconds until the given offset. . Very useful for maximumLifetime
on the @cache
entry.
string
(string) The offset inDateInterval
format starting from midnightdateinerval
(boolean, optional) true if interval should be used or the $offset should be parsed, defaults totrue
In this example, we clear the cache at midnight by adding an offset of 0 hours.
@cache {
mode = 'cached'
maximumLifetime = ${Carbon.Date.secondsUntil('PT0H')}
...
}
To get the seconds until next year, you can do it like this:
secondUntilNextYear = ${Carbon.Date.secondsUntil('first day of January next year', false)}
Return The timespan in seconds (integer)
Carbon.Date.timeToDateInterval(string)
Convert time duration (1:00) into a DateInterval
Return The duration as DateInterval