line_numbers
Prepends each line of the input with a line number counting up from a given start line, so `line_numbers:6` renders a block as if it began at line six.
InputArgumentsReturns
Sourcestringintstringstringno argumentsstringBasicSource
Starts the numbering at a given line, so a snippet lifted from the middle of a file lines up with its real position.
Given
{"body": "return nil\n}"}Template
{{ body | line_numbers:6 }}Result
6. return nil
7. }BasicSource
Prepends each line of a string with its one-based line number.
Given
{"body": "first\nsecond\nthird"}Template
{{ body | line_numbers }}Result
1. first
2. second
3. thirdSingleSource
Numbers a single line, which becomes line one.
Given
{"body": "only one line"}Template
{{ body | line_numbers }}Result
1. only one lineStepsSource
Numbers each line of a block from one, handy for turning a list of steps or a code snippet into a numbered listing.
Given
{"body": "clone the repo\nrun the build\nrun the tests"}Template
{{ body | line_numbers }}Result
1. clone the repo
2. run the build
3. run the tests