Skip to main content

before_line

Returns a string which is the subset of all lines of haystack before line number line_number and not including line number line_number itself. If `haystack` contains fewer than line_number number of lines, will return the entire contents of `haystack`.

Usage

{{before_line haystack line_number flags="t"}}

Arguments

haystack
The input string.

line_number
The boundary line number

flags

  • t: trim the final result prior to returning (remove all whitespace from beginning and end)

Examples

Return the first 2 lines

{{before_line email.body '3' flags='t'}}
Line 1.
Line 2.

Return all lines when the requested line doesn't exist

{{before_line email.body '15' flags='t'}}
This is line 1.
This is line 2.
This is line 3.
This is line 4.