StringLoader

Loads string templates, also known as inline templates.

This loader is intended to be used in a Twig loader chain and whitelists string templates that begin with the following comment:

{# inline_template_start #}

This class override ensures that the string loader behaves as expected in the loader chain. If Twig's string loader is used as is, any string (even a reference to a file-based Twig template) is treated as a valid template and is rendered instead of a \Twig_Error_Loader exception being thrown.

Hierarchy

  • class \Drupal\Core\Template\Loader\StringLoader implements Twig_ExistsLoaderInterface, Twig_LoaderInterface

See also

\Drupal\Core\Template\TwigEnvironment::renderInline()

\Drupal\Core\Render\Element\InlineTemplate

twig_render_template()

File

core/lib/Drupal/Core/Template/Loader/StringLoader.php, line 23

Namespace

Drupal\Core\Template\Loader

Members

Name Modifiers Type Description
StringLoader::exists public function Check if we have the source code of a template, given its name. Overrides Twig_ExistsLoaderInterface::exists
StringLoader::getCacheKey public function Gets the cache key to use for the cache for a given template name. Overrides Twig_LoaderInterface::getCacheKey
StringLoader::getSource public function Gets the source code of a template, given its name. Overrides Twig_LoaderInterface::getSource
StringLoader::isFresh public function Returns true if the template is still fresh. Overrides Twig_LoaderInterface::isFresh
doc_Drupal
2016-10-29 09:45:14
Comments
Leave a Comment

Please login to continue.