Arrays

You are here:

Working With Arrays

These filters help you in working with arrays.

 

Abs

Show Details

Returns the absolute or unsigned value of any input that can be converted to a number.

 

AddCssLink

Show Details

Adds a CSS link to the page. If the link has already been previously registered (by a block or other Lava) it will not be duplicated.

 

AddLinkTagToHead

Show Details

Adds a link to the HTML head of the current page.

 

AddMetaTagToHead

Show Details

Creates a meta tag that will be inserted into the HTML head. This is useful for adding social media links.

 

AddResponseHeader

Show Details

Adds a header to the HTTP response. This allows you to set custom headers. Note that any headers already being set in Rock will overwrite the values you provide. These should only be used to add custom headers.

 

Address

Show Details

Provides an address for the person you provide.

 

AddScriptLink

Show Details

Adds a script link to the page. If the link has already been previously registered (by a block or other Lava) it will not be duplicated.

 

AddSegment

Show Details

Adds a person to one or more personalization segments.

 

AddToArray

Show Details

Add a new item to an existing array.

 

AddToDictionary

Show Details

Takes an existing (or empty) dictionary and returns a new dictionary with the added key and value.

 

AddToMergeFields

Show Details

Allows you to add a new item to the provided Lava merge fields.

 

AdjustHue

Show Details

Adjusts the hue by the specified percentage (10%) or degrees (10deg).

 

AllKeysFromDictionary

Show Details

Retrieves all keys that exist in the dictionary object and returns them in an array.

 

Append

Show Details

Adds a given string to the end of the input.

 

AppendFollowing

Show Details

Returns the following status for the currently logged in user to the results of an entity command or Persisted Dataset.

 

AppendSegments

Show Details

Adds personalization segment information for the currently logged in user to the results of an entity command or Persisted Dataset.

 

AppendWatches

Show Details

Returns information about whether the current person has watched various media files provided. This filter is highly customizable to work in various different scenarios.

 

AsBoolean

Show Details

Converts the input to a Boolean (true/false) value.

 

AsDateTime

Show Details

Converts the input to a DateTime value.

 

AsDateTimeUtc

Show Details

Converts the input to a DateTime value in Coordinated Universal Time (UTC).

 

AsDecimal

Show Details

Converts the input to a decimal value.

 

AsDouble

Show Details

Converts the input to a double value (which has less precision than a decimal).

 

AsGuid

Show Details

Converts the input to a Guid value.

 

AsInteger

Show Details

Converts the input to an integer value.

 

AsString

Show Details

Converts the input to a string value.

 

AtLeast

Show Details

Limits a number to a minimum value.

 

AtMost

Show Details

Limits a number to a maximum value.

 

Base64Encode

Show Details

Converts a binary file to a base-64 encoded string.

 

Campus

Show Details

Campus returns the person's campus. Since a person can have more than one campus (if they are a part of more than one family) the first campus will be provided. If you would like an array of all their campuses you can provide the 'All' extension.

 

Capitalize

Show Details

Capitalizes the first letter of each word in the string. The string 'lorem ipsum dolor' would become 'Lorem Ipsum Dolor'.

 

Ceiling

Show Details

Takes a number and returns the next largest integer.

 

Children

Show Details

Returns a list of children for the person

 

Client

Show Details

Returns information about the client browser.

 

Compact

Show Details

Removes empty or null values from an array.

 

Concat

Show Details

Joins multiple arrays together so that the result contains all the items from the input arrays.

 

Contains

Show Details

The contains filter returns true if the specified value is in the array

 

CreateEntitySet

Show Details

Creates a new EntitySet from a list of entity identifiers of the specified type.

 

CreateShortLink

Show Details

Creates a URL short link for the provided URL.

 

Darken

Show Details

Darkens the color by a provided percentage.

 

Date

Show Details

Displays the date given a format string. The string 'Now' can be used for the current date/time.

 

DateAdd

Show Details

Adds a span of time to a provided date (default is in days).

 

DateDiff

Show Details

Takes two datetimes and returns the difference in the unit you provide. You can provide the value 'Now' for either the start or end date.

 

DateRangeFromSlidingFormat

Show Details

Provides a start and end date from a sliding date range format (typically from the Sliding Date Range control).

 

DatesFromICal

Show Details

Returns a list of upcoming dates from an iCal string or List of iCal strings.

 

DaysFromNow

Show Details

Returns a humanized string of the number of days from now without concern for time.

 

DaysInMonth

Show Details

Returns the number of days in the month you provide.

 

DaysSince

Show Details

Returns the number of days that have passed since a given date.

 

DaysUntil

Show Details

Returns the number of days from now.

 

Debug

Show Details

The debug filter provides you with a ton of information on the variables you have access to in your Lava.

 

Decrypt

Show Details

Decrypts an encrypted value.

 

Default

Show Details

Returns the passed default value if the value is undefined or empty, otherwise the value of the variable.

 

DeleteUserPreference

Show Details

Rock has the concept of saved settings / preferences for each user. This filter allows you to clean up the setting based on its key.

 

Desaturate

Show Details

Desaturates (mutes) the color by a provided percentage.

 

Distinct

Show Details

Takes an array as input and returns the distinct (unique) elements of the array.

 

DividedBy

Show Details

Divides a number by the number provided.

 

Downcase

Show Details

This filter transforms all characters in the string to lower case. The string 'LoRem IpSum DoLor' would become 'lorem ipsum dolor'.

 

Encrypt

Show Details

Encrypts a string of text using the encryption key configured for the current Rock instance.

 

EntityFromCachedObject

Show Details

Returns a full entity object loaded from the database from its cached counterpart.

 

Escape

Show Details

HTML encode string. All <tags> will be encoded to '&lt;tags&gt;'

 

EscapeDataString (aka UrlEncode)

Show Details

Converts a string to its escaped representation using Uri.EscapeDataString (aka URL Encoding).

 

EscapeOnce

Show Details

HTML encodes a string without changing any existing encoding. All <tags> will be encoded to '&lt;tags&gt;', whereas previously encoded text such as '&lt;tags&gt;' won't be modified.

 

FadeIn

Show Details

Decreases the opacity level by the given percentage. This makes the color less transparent (opaque).

 

FadeOut

Show Details

Increases the opacity level by the given percentage. This makes the color more transparent.

 

FamilySalutation

Show Details

Returns the salutation of the family for a given person.

 

FilterFollowed

Show Details

Returns a subset of followed entities for the current user from either a Persisted Dataset or an entity command.

 

FilterUnfollowed

Show Details

Returns a subset of entities that have not been followed by the current user from either a Persisted Dataset or an entity command.

 

First

Show Details

Returns the first item from an array/collection.

 

Floor

Show Details

Takes a number and returns the next smallest integer.

 

Format

Show Details

Formats the number based on a pattern you provide.

 

FormatAsCurrency

Show Details

Provides a simple way to display an internationalized currency amount. The filter uses the currency symbol defined in the 'OrganizationCurrencyCode' global attribute.

 

FromBase64

Show Details

Decodes the base 64 encoded string and returns the resulting data.

 

FromCache

Show Details

Reads objects from the Rock cache which will reduce the number of database reads your Lava produces.

 

FromIdHash

Show Details

Returns a Rock Entity Id from an IdHash string generated by the ToIdHash filter.

 

FromJSON

Show Details

Takes a JSON string and makes a Lava object from it.

 

FromMarkdown

Show Details

Converts a string of Markdown to HTML. See the Commonmark website for details on Markdown syntax.

 

GeofencingGroupMembers

Show Details

Returns a collection of group members whose groups geofence the person's map location address.

 

GeofencingGroups

Show Details

Returns a collection of groups that geofence the person's map location address.

 

GetPersonAlternateId

Show Details

Returns the person's alternate id.

 

GetUserPreference

Show Details

Rock has the concept of saved settings / preferences for each user. This filter allows you to retrieve the setting based on its key. This is a great way of remembering something about the user (like settings from the last time they ran something) for use when they return.

 

Grayscale

Show Details

Returns the color in greyscale.

 

Group

Show Details

Returns group member information if a person is in a specific group.

 

GroupBy

Show Details

Takes a collection of items and groups them by the specified property tree value.

 

GroupByGuid

Show Details

Returns a full Group object from the Guid of the group.

 

GroupById

Show Details

Provides a full Group object by providing an Id of the group.

 

Groups

Show Details

Returns a list of group member models of a specified group type that an individual belongs to.

 

GroupsAttended

Show Details

Returns a list of groups that a person attended within a provided group type.

 

GuidToId

Show Details

Converts one or more entity Guid identifiers to corresponding Id values for the specified entity type.

 

HasRightsTo

Show Details

This filter helps you check the security of the model you pass it.

 

HasSignedDocument

Show Details

Allows you to determine if someone has already signed a document.

 

HeadOfHousehold

Show Details

Returns the head of household of the provided person.

 

HmacSha1

Show Details

Converts a string into a SHA-1 hash using a hash message authentication code (HMAC).

 

HmacSha256

Show Details

Converts a string into a SHA-256 hash using a hash message authentication code (HMAC).

 

HtmlDecode

Show Details

Decodes an escaped string of HTML.

 

Humanize

Show Details

This filter takes computer friendly strings like 'camelCase', 'underscore_a_point' or 'css-classes' and makes them friendly to us humans... 'Camel case', 'underscore a point' or 'css classes'.

 

HumanizeDateTime

Show Details

Compares the provided date/time to the current date/time and returns a human friendly string like 'yesterday' or '2 hours ago'.

 

HumanizeTimeSpan

Show Details

Takes two datetimes and humanizes the difference like '1 day'. Supports 'Now' in either the start or end date.

 

ImageUrl

Show Details

Simplifies making an image URL with a fallback.

 

Index

Show Details

Provides an easy way to retrieve an item from an array using its index when chaining filters.

 

Indexer

Show Details

Returns the item at the specified index location in an array. Note that array numbering starts from zero, so the first item in an array is referenced with [0].

 

IsDateBetween

Show Details

Determine if the provided date falls within a given range.

 

IsFollowed

Show Details

Takes an entity object as input and tests if it is being followed by the current person. Returns a boolean value of either true or false.

 

IsInDataView

Show Details

Takes the given Entity or Entity Id and returns a boolean that indicates whether the entity is in the data view or not.

 

IsInSecurityRole

Show Details

Takes the given person object and tests if they are the given security role. Returns a boolean value of either true or false.

 

Join

Show Details

Combines the properties of an array with the character passed as the parameter.

 

Last

Show Details

Returns the last item from an array/collection.

 

LastAttendedGroupOfType

Show Details

Returns the latest attendance record for a group of the type given.

 

Lighten

Show Details

Lightens the color by a provided percentage.

 

Linkify

Show Details

Convert strings within the text that appear to be http/ftp/https links into clickable html links

 

Map

Show Details

Takes a property of the array as a parameter and creates a string out of each array property value.

 

Md5

Show Details

Converts a string into an MD5 hash.

 

Minus

Show Details

Subtracts a number from the number provided.

 

Mix

Show Details

Mixes the specified color with the input color with the given amount.

 

Modulo

Show Details

The modulo filter returns the remainder of division of one number by another.

 

NearestCampus

Show Details

Gets the nearest campus or campuses for a person's mapped location address.

 

NearestGroup

Show Details

Returns the nearest group of a specified group type to the person's mapped location address.

 

NewlineToBr

Show Details

Add <br/> tags in front of all newlines in the string

 

NextDayOfTheWeek

Show Details

Advances the date to a specific day in the next 7 days.

 

Notes

Show Details

Retrieves notes for the provided entity.

 

NumberToOrdinal

Show Details

Takes 1, 2 or 3 and returns 1st, 2nd or 3rd.

 

NumberToOrdinalWords

Show Details

Takes 1, 2 or 3 and returns first, second or third.

 

NumberToRomanNumerals

Show Details

For those Latin lovers, this filter takes a number and returns its Roman numeral equivalent.

 

NumberToWords

Show Details

Takes 1, 2 or 3 and returns one, two or three.

 

ObfuscateEmail

Show Details

Hides the details of an email address with enough information to confirm that it was sent to an address the user would recognize.

 

OrderBy

Show Details

Orders a collection of elements by the specified property tree and returns a new collection in that order.

 

Page

Show Details

Returns information about the current page.

 

PageParameter

Show Details

Returns the value of a specified page parameter.

 

PageRedirect

Show Details

Will redirect the page to the provided URL.

 

PageRoute

Show Details

Converts a page identifier into a URL string.

 

Parents

Show Details

Returns a list of the adults in the family of a specified person.

 

PersistedDataset

Show Details

Returns data contained in a Persisted Dataset as a Lava object.

 

PersonActionIdentifier

Show Details

Creates a non-security type token that identifies a person and a corresponding action. This action is intended for use by developers.

 

PersonalizationItems

Show Details

Returns an array of personalization items for the specified person and the current page context.

 

PersonByAliasGuid

Show Details

Returns a full person object from the Guid of a person alias.

 

PersonByAliasId

Show Details

Returns a full person object from the Id of a person alias.

 

PersonByGuid

Show Details

Returns a full person object from the Guid of the person.

 

PersonById

Show Details

Returns a full person object from the Id of the person.

 

PersonByPersonActionIdentifier

Show Details

Retrieves a person using a generated action identifier and the corresponding action. The action should be the same one used when the token was created.

 

PersonByPersonAlternateId

Show Details

Returns a person from the provided alternate id.

 

PersonImpersonationToken

Show Details

Appends an impersonation token (with rckipid key) to the end of a URL. It's smart enough to handle URLs with and without query string parameters. If the URL is blank, it will return just the token itself.

 

PersonTokenCreate

Show Details

Creates a person token for a provided person.

 

PersonTokenRead

Show Details

Converts a person token to a person object.

 

PhoneNumber

Show Details

Provides a phone number for the person you provide.

 

Pluralize

Show Details

Pluralizes the provided input while taking irregular and uncountable words into consideration.

 

PluralizeForQuantity

Show Details

Pluralizes the provided word if the quantity provided neither 1 (or -1).

 

Plus

Show Details

Adds a number to the number provided.

 

Possessive

Show Details

Returns the possessive form of the string.

 

Postback

Show Details

This is a very specialized Lava filter that helps to wire-up ASP.Net postbacks. This is only available on specific blocks that provide 'Postback Commands'. The 'Group Details Lava' is an example of a block that provides these hooks.

 

Prepend

Show Details

Adds a given string to the beginning of the input.

 

Property

Show Details

Returns the property of a provided object. This often saves you from having to assign an object to a variable to get just one of its properties.

 

PropertyToKeyValue

Show Details

Takes a property and returns it as a key/value pair. This is helpful for iterating over a list of properties.

 

RandomNumber

Show Details

Generates a random number between 0 and up to (but not including) the number you pass in as input.

 

ReadCookie

Show Details

Gets the value of a HTTP cookie for the current user session.

 

ReadTime

Show Details

Calculates the approximate reading time for a given string.

 

RegExMatch

Show Details

Tests the input against a Regular Expression to determine if it is a match.

 

RegExMatchValue

Show Details

Tests the input against a Regular Expression and returns the matching substring if a match is made; otherwise it returns nothing.

 

RegExMatchValues

Show Details

Tests the input against a Regular Expression and returns an array of the matching substrings. If no match is made, it will return an empty array.

 

RegExReplace

Show Details

Replaces a portion of the string passed as the input to the filter with Regular Expression matching.

 

Remove

Show Details

Remove all occurrences of a given string.

 

RemoveFirst

Show Details

Removed the first occurrence of a given string.

 

RemoveFromArray

Show Details

Take a collection of objects and return a new collection which does not contain the specified value.

 

RemoveFromDictionary

Show Details

Removes the specified key from a dictionary of keys and values.

 

RenderStructuredContentAsHtml

Show Details

Takes the given structured content and renders it as HTML.

 

Replace

Show Details

Replace all occurrences of a given string.

 

ReplaceFirst

Show Details

Replace the first occurrence of a given string.

 

ReplaceLast

Show Details

Replaces the last occurrence of a string pattern with a new value.

 

ResolveRockUrl

Show Details

This filter helps to resolve the application path in Rock using ~/ for the application home and ~~/ for the theme home. This is helpful when writing Lava that may be used by several organizations.

 

Reverse

Show Details

Reverses the order of the items in an array.

 

Right

Show Details

Returns the right most part of a string of the given length.

 

RockInstanceConfig

Show Details

Shows configuration values for the current Rock instance.

 

Round

Show Details

Rounds a number to the nearest integer, or to a specified number of decimal places.

 

RunLava

Show Details

Executes Lava that is inside a string.

 

SanitizeSql

Show Details

Accepts a string as input and sanitizes it for use in a SQL statement.

 

Saturate

Show Details

Saturates (makes the color richer) the color by a provided percentage.

 

Select

Show Details

Returns a single property from an object.

 

SentenceCase

Show Details

Changes the string to be in sentence case.

 

SetPageTitle

Show Details

Takes a string as input and sets the page's title.

 

SetUrlParameter

Show Details

Sets a parameter in the input URL string and returns the updated URL.

 

SetUserPreference

Show Details

Rock has the concept of saved settings / preferences for each user. This filter allows you to save the setting based on its key and provided value. This is a great way of remembering something about the user (like settings from the last time they ran something) for use when they return.

 

Sha1

Show Details

Converts a string into a SHA-1 hash.

 

Sha256

Show Details

Converts a string into a SHA-256 hash.

 

Shade

Show Details

Shades (adds black) the specified color by the specified amount.

 

Shuffle

Show Details

Randomizes the order of an array. Useful for ads on a homepage where you'd like a different ad to be first for each visit.

 

Singularize

Show Details

It’s like the antidote to pluralize. Makes plural words singular.

 

Size

Show Details

Returns the length of the string, including all characters and spaces.

 

Size

Show Details

Provides the number of items in the array.

 

Slice

Show Details

The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.

 

Slice (arrays)

Show Details

The slice filter (when used on an array) returns a subset of the given array, starting at the specified index. An optional second parameter can be passed to specify the length of the subset. If no second parameter is given, a subset of one item will be returned.

 

Sort

Show Details

Sorts a primitive array (in case-sensitive order in Fluid). To sort by the properties of an array, use OrderBy.

 

SortByAttribute

Show Details

Sorts an array of items based on an attribute value.

 

SortNatural

Show Details

Fluid only: Sorts a primitive array, in case-insensitive order. To sort by the properties of an array, use OrderBy.

 

Split

Show Details

Splits a string into an array based on a matching pattern.

 

Spouse

Show Details

Returns the spouse of the provided person.

 

Steps

Show Details

Returns a filtered list of steps that the person has engaged with.

 

StripHtml

Show Details

Remove all HTML tags from the string.

 

StripNewlines

Show Details

Remove all new line characters (\r\n) from the string.

 

Sum

Show Details

Performs a mathematical summation of all numeric values in an array and outputs the result.

 

SundayDate

Show Details

Returns the Sunday date portion (without any time portion) of the date provided.

 

TimeOfDay

Show Details

Returns a description of the time of day for an input value that represents a date/time. The keyword 'Now' can be used to represent the current time.

 

Times

Show Details

Multiplies a number by the number provided.

 

Tint

Show Details

Tints (adds white) the specified color by the specified amount.

 

TitleCase

Show Details

Takes an ordinary string like 'of mice and men' and makes it usable as a title, 'Of Mice And Men'.

 

ToCssClass

Show Details

Converts string to a CSS class name format (e.g. home-phone).

 

ToIdHash

Show Details

Returns an alphanumeric string that can be used to uniquely identify a Rock Entity.

 

ToJSON

Show Details

Returns a JSON representation of the object. This is useful if you are wanting to return the object for use in JavaScript.

 

ToMidnight

Show Details

Sets the time to midnight for a specific day.

 

ToPascal

Show Details

For all the programmers in the house. This will take a string and return it back in PascalCase.

 

ToQuantity

Show Details

Many times you want to call Singularize and Pluralize to prefix a word with a number; e.g. "2 requests", "3 men". ToQuantity prefixes the provided word with the number and accordingly pluralizes or singularizes the word.

 

ToString

Show Details

Converts a number to a string.

 

Trim

Show Details

Removes all blank spaces (or instances of an optional character string) from the beginning and end of the input string.

 

TrimEnd

Show Details

Removes all blank spaces (or instances of an optional character string) from the end of the input string.

 

TrimStart

Show Details

Removes all blank spaces (or instances of an optional character string) from the beginning of the input string.

 

Truncate

Show Details

Will shorten the input down to the provided size and append an optional string to the end. The length of the appending string will be counted in the truncate size. If no appending string is provided '...' will be used.

 

TruncateWords

Show Details

Shortens the input to the number of words provided and appends an optional string to the end. If no appending string is provided it will use '...'.

 

UnescapeDataString (aka UrlDecode)

Show Details

Converts a string to its escaped representation using Uri.EscapeDataString (aka URL Decoding).

 

Uniq

Show Details

Takes a collection of values and returns only the unique set of those values.

 

UniqueIdentifier

Show Details

Generates a new GUID (UUID) string. These are generally considered to be globally unique. This makes them ideal to use inside a shortcode where you need to identifier an HTML element by id but know the shortcode may be used twice on the same page.

 

Upcase

Show Details

This filter transforms the string to all upper case. The string 'Lorem Ipsum Dolor' would become 'LOREM IPSUM DOLOR'.

 

Url

Show Details

The Url filter allows you to easily get access to parts of a URL without a ton of string manipulation.

 

Where

Show Details

This filter allows you to filter a collection of items by a key and value.

 

WithFallback

Show Details

This filter allows you to eliminate conditional tests for null or empty values by allowing you to provide fallback text.

 

WriteCookie

Show Details

Sets a HTTP cookie for the current user session. Cookies provide a means of storing information about the current user's session that can be accessed in subsequent requests.

 

XamlWrap

Show Details

Wraps XAML in CDATA tags to make it XML compliant.

 

ZebraPhoto

Show Details

Returns a person's profile photo data in ZPL format for use in Zebra printer labels. If the person has no photo, the default silhouette photo (adult/child, male/female) is used.

Array Filters In Action

Reading through the filters above you might question the value of many of them. For instance what good is the 'Map' filter when it just returns a string of array values all smashed together (Avalon CampusTacoma CampusCorolla Campus). The power comes when you chain these filters together. Consider the kitchen sink example below.

{% assign sortedCampuses = Campuses | Sort:'Name' %}
{{ sortedCampuses | Map:'Name' | Join:', ' | ReplaceLast:',',' and' }}

Output:
Avalon Campus, Corolla Campus and Tacoma Campus
Subscribe To Our Newsletter

Rock is a project of the Spark Development Network.