Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StringLoaderExtension.php

class StringLoaderExtension

Hierarchy

  • class \Twig\Extension\AbstractExtension implements \Twig\Extension\ExtensionInterface
    • class \Twig\Extension\StringLoaderExtension extends \Twig\Extension\AbstractExtension

Expanded class hierarchy of StringLoaderExtension

1 file declares its use of StringLoaderExtension
string_loader.php in vendor/twig/twig/src/Resources/string_loader.php

File

vendor/twig/twig/src/Extension/StringLoaderExtension.php, line 18

Namespace

Twig\Extension
View source
final class StringLoaderExtension extends AbstractExtension {
    public function getFunctions() : array {
        return [
            new TwigFunction('template_from_string', [
                self::class,
                'templateFromString',
            ], [
                'needs_environment' => true,
            ]),
        ];
    }
    
    /**
     * Loads a template from a string.
     *
     *     {{ include(template_from_string("Hello {{ name }}")) }}
     *
     * @param string|null $name An optional name of the template to be used in error messages
     *
     * @internal
     */
    public static function templateFromString(Environment $env, string|\Stringable $template, ?string $name = null) : TemplateWrapper {
        return $env->createTemplate((string) $template, $name);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AbstractExtension::getFilters public function Returns a list of filters to add to the existing list. Overrides ExtensionInterface::getFilters 4
AbstractExtension::getNodeVisitors public function Returns the node visitor instances to add to the existing list. Overrides ExtensionInterface::getNodeVisitors 9
AbstractExtension::getOperators public function Returns a list of operators to add to the existing list. Overrides ExtensionInterface::getOperators 1
AbstractExtension::getTests public function Returns a list of tests to add to the existing list. Overrides ExtensionInterface::getTests 2
AbstractExtension::getTokenParsers public function Returns the token parser instances to add to the existing list. Overrides ExtensionInterface::getTokenParsers 5
StringLoaderExtension::getFunctions public function Returns a list of functions to add to the existing list. Overrides AbstractExtension::getFunctions
StringLoaderExtension::templateFromString public static function Loads a template from a string.
RSS feed
Powered by Drupal