TemplateLoader

Type
Class
Namespace
Craft
Inherits
Craft\TemplateLoader
Implements
Twig_ExistsLoaderInterface, Twig_LoaderInterface
Since
1.0

Loads Craft templates into Twig.

See also http://craftcms.com

View source

Public Methods

MethodDescription
exists()Checks if a template exists.
getCacheKey()Gets the cache key to use for the cache for a given template.
getSource()Gets the source code of a template.
isFresh()Returns whether the cached template is still up-to-date with the latest template.

exists()

Checks if a template exists.

View source

Arguments

Returns

boolean

Signature

public boolean exists ( $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, or a StringTemplate object.

Returns

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

Signature

public string getCacheKey ( $name )

getSource()

Gets the source code of a template.

View source

Arguments

  • $name (string) – The name of the template to load, or a StringTemplate object.

Returns

string – The template source code.

Throws

Signature

public string getSource ( $name )

isFresh()

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

View source

Arguments

  • $name (string) – The template name, or a StringTemplate object.
  • $time (integer) – The last modification time of the cached template

Returns

boolean

Signature

public boolean isFresh ( $name, $time )