Data Functions

Data functions operate at render time with the data returned by the controller / model.

first( collection )

Returns:

The first or only item in the collection

Parameters

collection
IEnumerable

The collection from which the first item is fetched. If parameter is not IEnumerable, null is returned - this might change so that a non-IEnumerable, would be considered an IEnumerable of length 1 (would apply to all collection functions).

Example:

text-add: get(first(data(CustomerList)), Name);

 

last( collection )

Returns:

The last or only item in the collection

Parameters

collection
IEnumerable

The collection from which the last item is fetched. If parameter is not IEnumerable, null is returned.

Example:

text-add: get(last(data(CustomerList)), Name);

 

rest( collection )

Returns:

All, but the first item in the collection

Parameters

collection
IEnumerable

The collection from which the items are returned. If parameter is not IEnumerable or there is only one item in collection, null is returned.

Example:

apply-template-add: rest(data(CustomerList)) customerRowTemplate;

 

trunc( collection )

Returns:

All, but the last item in the collection

Parameters

collection
IEnumerable

The collection from which the items are returned. If parameter is not IEnumerable or there is only one item in collection, null is returned.

Example:

apply-template-add: trunc(data(CustomerList)) customerRowTemplate;

 

strip( collection )

Returns:

The collection without null values

Parameters

collection
IEnumerable

The collection from which the the non-null items are filtered. If parameter is not IEnumerable, null is returned.

Example:

/* Would apply the template to non-null values of the customer list */
apply-template-add: strip(data(CustomerList)) customerRowTemplate;

 

length( collection )

Returns:

The length of the collection

Parameters

collection
IEnumerable

The collection to count. If parameter is not IEnumerable, null is returned.

Example:

text-add: length(data(CustomerList));

 

join( collection, separator )

Returns:

Concatenates all items in the collection.

Parameters

collection
IEnumerable

The collection from which is concatenated. If parameter is not IEnumerable, null is returned.

separator
text, optional, default: ', '

Separator that is put between the items. If null, separator is ", ".

Example:

/* Used in this page to print the function list */
text: concat(item(functionName), "( ", join(item(paramNames)), " )");

 

item( property path )

Returns:

Data object from the current item passed to a template.

Parameters

property path
string, optional, default: null

Property path is in format "firstProperty.secondProperty.nthProperty", if omitted, the whole item is returned. Property path is resolved at runtime, so it can also be active data from controller resulting to indirect property lookup.

Example:

@template customerRowTemplate "#indexExampleRow"
{
  td:nth-child(1) { text-inner: index() }
  td:nth-child(2) { text-inner: index(1) }
  td:nth-child(3) { text-inner: item(Name) }
}

 

index( base )

Returns:

Zero-based index number of the current item adding the base number if it can be converted to integer.

Parameters

base
number, optional, default: 0

Base number that is added to zero-based index value. Index() and index(0) result to zero-based index; index(1) results to one-based index.

Example:

@template customerRowTemplate "#indexExampleRow"
{
  td:nth-child(1) { text-inner: index() }
  td:nth-child(2) { text-inner: index(1) }
  td:nth-child(3) { text-inner: item(Name) }
}

 

get( container, property path )

Returns:

A property from any object. Mostly used, when you need to fetch a property from a function result, e.g. "get(first(coll), Name)".

Parameters

container
object

Object from which the property value is fetched.

property path
string, optional, default: null

Property path is in format "firstProperty.secondProperty.nthProperty", if omitted, the whole container object is returned. Property path is resolved at runtime, so it can also be active data from controller resulting to indirect property lookup.

Example:

/* Renders the Name property from the last item in the CustomerList collection */
#lastItemExample
{
  text: get(last(data(CustomerList)), Name);
}
    

 

data( property path )

Returns:

Data from the ViewData object.

Parameters

property path
string, optional, default: null

Property path is in format "firstProperty.secondProperty.nthProperty", if omitted, the ViewData object is returned. Property path is resolved at runtime, so it can also be active data from controller resulting to indirect property lookup.

Example:

#returns p { text: item(returns); }

 

model( property path )

Returns:

Gets data from the ViewData.Model object.

Parameters

property path
string, optional, default: null

Property path is in format "firstProperty.secondProperty.nthProperty", if omitted, the ViewData.Model object is returned. Property path is resolved at runtime, so it can also be active data from controller resulting to indirect property lookup.

Example:

p { text: model(SomeProperty); }

 

concat( value1, value2, valueN )

Returns:

Concatenates string values - may have any number of parameters.

Parameters

value1
text, optional, default: null

First item to concatenate.

value2
text, optional, default: null

Second item to concatenate

valueN
text, optional, default: null

Nth item to concatenate

Example:

/* Used in this page to print the function list */
text: concat(item(functionName), "( ", join(item(paramNames)), " )");

 

if( condition, value if true, value if false )

Returns:

Second parameter if condition is true and third parameter if condition is false.

Parameters

condition
object

Object to be evaluated. If object is boolean, the boolean value is used. If object is of any other type, null is false and any value is true.

value if true
object

Value if condition returns boolean true or a non-null object.

value if false
object, optional, default: null

Value if condition returns boolean false or a null object.

Example:

li { style-add: if(item(isKeyCustomer), "background-color: red", "") }

 

isnull( value, value if null )

Returns:

Second parameter if the first parameter is null, otherwise the first parameter.

Parameters

value
object

Object to be evaluated. Returned, if non-null. If null, the second parameter is returned.

value if null
object

Value if the first parameter is null.

Example:

/* in this page, renders the example or placeholder text, if data has no example
pre { text: isnull(item(example), "-- TO BE ADDED --" ;}

 

false( )

Returns:

Boolean value false.

Parameters

Example:

 

null( )

Returns:

Returns a null value.

Parameters

Example:

-- TO BE ADDED --

 

true( )

Returns:

Boolean value true. Just for consistency (corresponding to false() and null()), basically any text value results to true.

Parameters

Example:

-- TO BE ADDED --