Skip to main content

Indentation Control

Although running your projects code style tooling after generating code is recommended, some basic indentation controls are also provided.

Indent

The indent method will increase the indent level of the code

Deindent

The deindent method will decrease the indent level of the code

Stencil::make()
->newline()
->indent()
->line('Hello')
->line('World')
->deintent()
->line('Tada!')
// --- results in --- //
"
••••Hello
••••World
Tada!
"

Indented

The indented method will indent the content passed, and then return the indent level to the previous level

Stencil::make()
->newline()
->indented('Hello')
->line('World')
// --- results in --- //
"
••••Hello
World
"

SetIndentLevel

The setIndentLevel method will set the current indent level to a specific value

Stencil::make()
->line('Hello')
->setIndentLevel(2)
->line('World')
// --- results in --- //
"Hello
••••••••World
"

SpacesPerIndent

The spacesPerIndent changes the number of spaces when the indent or indented method is used

Stencil::make()
->newline()
->spacesPerIndent(2)
->indent()
->line('Hello')
// --- results in --- //
"
••Hello
"