The limit
function allows you to limit the number of results in a looped output. For more information on loops, please see this article on Variables and Collections.
Syntax
{collectionVariable | filter:'filterVariable':'filterValue' | limit:number}
Since we are not opening the collection, and this is not logic, there are no {#} opening tags or {/} closing tags required.
💡 Always use the |
Sample Share Classes Data |
Common (voting) - 100 issued and outstanding Class A Special (non-voting) - 25 issued and outstanding Class A Common (voting) - 150 issued and outstanding Class B Special (non-voting) - 10 issued and outstanding Class B Common (voting) - 150 issued and outstanding Class C Special (non-voting) - 5 issued and outstanding Class C Common (voting) - 150 issued and outstanding Preferred (non-voting) - 50 issued and outstanding |
Using limit
To list the first share class that has voting rights attached:
Input | {#shareclasses | filter:'votingRights':'true' | limit:1}{className}{/} |
Output | Common |
Using limit with Sorted Data
To list the top 5 share classes based on the number of shares issued and outstanding:
Input |
{#shareclasses | orderBy_B:'!totalOutstanding' | limit:5}{className} {/} |
Output |
Class A Common Class B Common Class C Common Common Preferred |
For more information on using limit
function in conjunction with sorting functions, check out Sorting and Ordering Data.