Tutorials References Exercises Bootcamp Menu
Sign Up Create Website Get Certified Upgrade

Template Filter - first


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:


Return the first character of a string:

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

Use the last filter to return the last item.


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

{{ value|first }}