View

View functions help leverage the view engine.

view

The view function returns a rendered view.

The single most important detail of this function versus using Twig's include is that the view is passed through the view composer in order to allow overriding. Overriding on the other hand is not supported with the include tag.

Returns: string
Arguments
Key Required Type Default Description

$view

true

string

none

The view you wish to render.

$data

false

array

null

The data to pass along to the view.

Twig
{{ view('example.module.test::example/view', {'foo': 'Bar'}) }}

parse

The parse function parses a string template.

Returns: string
Arguments
Key Required Type Default Description

$template

true

string

none

The template string to parse.

$data

false

array

null

The data to pass along to the view.

Twig
{{ parse("This is a template {{ foo }}", {"foo": "bar"}) }}

layout

The layout method checks for a theme layout and returns a default if it's not found.

Returns: string
Arguments
Key Required Type Default Description

$layout

true

string

none

The layout to look for.

$default

false

string

default

The default layout to fallback to.

Twig
{% extends layout("posts") %} // extends "theme::layotus/default" if not found