3 namespace Drupal\Core\Template\Loader;
6 * Loads string templates, also known as inline templates.
8 * This loader is intended to be used in a Twig loader chain and whitelists
9 * string templates that begin with the following comment:
11 * {# inline_template_start #}
14 * This class override ensures that the string loader behaves as expected in
15 * the loader chain. If Twig's string loader is used as is, any string (even a
16 * reference to a file-based Twig template) is treated as a valid template and
17 * is rendered instead of a \Twig_Error_Loader exception being thrown.
19 * @see \Drupal\Core\Template\TwigEnvironment::renderInline()
20 * @see \Drupal\Core\Render\Element\InlineTemplate
21 * @see twig_render_template()
23 class StringLoader implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface {
28 public function exists($name) {
29 if (strpos($name, '{# inline_template_start #}') === 0) {
40 public function getSource($name) {
47 public function getCacheKey($name) {
54 public function isFresh($name, $time) {