Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

Template Filter - first


Example

Return the first item in a list:

<h1>{{ fruits|first }}</h1>
Run Example »

Definition and Usage

The first filter returns the first item of an object.

For strings, the first filter returns the first character:

Example

Return the first character of a string:

<h1>{{ firstname|first }}</h1>
Run Example »

Use the last filter to return the last item.


Syntax

Template filters are defined by using a pipe | character followed by the name of the filter.

{{ value|first }}