DEMOS / Binding with a Transform Function

The #bind{} element allows you to bind data to one or more elements using an efficient syntax. You define a list of data, a list of elements, and a map of where the data should be placed within the elements.

Optionally, you can specify a transform function on a #bind{} element. A transform function takes two parameters, the row of data, and an accumulator, and can be used to manipulate the data before it is ultimately bound to the list of elements.

This demo shows two transform functions in action, one to toggle the case of the supplied data, and one to change the row color.

View Module Source

Div Binding

Use a transform function to make the data alternately uppercase and lowercase.





Table Binding

Use a transform function to make the rows different colors.
TitleAuthorDescription
Title 1Author 1Description 1
Title 2Author 2Description 2
Title 3Author 3Description 3
Title 4Author 4Description 4
Title 5Author 5Description 5
Copyright © 2008-2024 Nitrogen Web Framework. Released under the MIT License.