Common Expressions
This plugin exposes some basic expressions into Player content.
It also serves as a good reference to adding your own custom expressions into Player.
Usage
CocoaPods
Add the subspec to your Podfile
Swift Usage
This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:
General
size
Gets the size of a value. This is the number of keys in an object, the length of a string, or the number of items in an array.
length
Alias for
size
concat
Concatenates arrays together, or strings into 1 value
Strings
trim
Trims whitespace from the leading and trailing edges of a string
upperCase
Transforms the string to all uppercase.
lowerCase
Transforms the string to all lowercase.
titleCase
Transforms the string to title case. Each word is capitalized.
sentenceCase
Transforms the string to sentence case. The first word is capitalized.
replace
Replaces all instances of pattern in string with replacement. The pattern can also be a regex.
containsAny
Checks if a given string contains any keywords present in the given array.
Math
number
Converts the given value to a number if possible. Will handle removing currency modifiers and comma delimitated values.
round
Rounds the given number to the nearest integer.
floor
Rounds the number down the the nearest integer
ceil
Rounds the number up the the nearest integer
sum
Sums up all arguments
Objects/Arrays
findPropertyIndex
Finds the index of the item in the given array (or array reference). Returns -1 for indexes that aren’t found
findProperty
Finds the item in the given array that matches the search criteria. Optionally return a specific property or a fallback value if not found