Skip to content

TemplateLoader

Type
Class
Namespace
craft\web\twig
Inherits
craft\web\twig\TemplateLoader
Implements
Twig\Loader\LoaderInterface
Since
3.0.0

Loads Craft templates into Twig.

View source

Protected Properties

PropertyDescription
viewcraft\web\View, null

view

Type
craft\web\View, null
Default value
null

View source

Public Methods

MethodDescription
__construct()Constructor
exists()
getCacheKey()Gets the cache key to use for the cache for a given template.
getSourceContext()
isFresh()Returns whether the cached template is still up to date with the latest template.

__construct()

Constructor

View source

Arguments

exists()

View source

Arguments

  • $name

getCacheKey()

Gets the cache key to use for the cache for a given template.

View source

Arguments

  • $name (string) – The name of the template to load

Returns

string – The cache key (the path to the template)

Throws

getSourceContext()

View source

Arguments

  • $name

isFresh()

Returns whether the cached template is still up to date with the latest template.

View source

Arguments

  • $name (string) – The template name
  • $time (integer) – The last modification time of the cached template

Returns

boolean

Throws