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

Breadcrumb

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

function EscaperExtension::setDefaultStrategy

Sets the default strategy to use when not defined by the user.

The strategy can be a valid PHP callback that takes the template name as an argument and returns the strategy to use.

Parameters

string|false|callable(string $templateName): string $defaultStrategy An escaping strategy:

1 call to EscaperExtension::setDefaultStrategy()
EscaperExtension::__construct in vendor/twig/twig/src/Extension/EscaperExtension.php

File

vendor/twig/twig/src/Extension/EscaperExtension.php, line 92

Class

EscaperExtension

Namespace

Twig\Extension

Code

public function setDefaultStrategy($defaultStrategy) : void {
    if ('name' === $defaultStrategy) {
        $defaultStrategy = [
            FileExtensionEscapingStrategy::class,
            'guess',
        ];
    }
    $this->defaultStrategy = $defaultStrategy;
}
RSS feed
Powered by Drupal