UNPKG

drupal-twig-extensions

Version:

JavaScript implementation of Drupal’s Twig extensions

54 lines (50 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.acceptedArguments = void 0; exports.activeTheme = activeTheme; exports.configInit = configInit; exports.options = exports.name = void 0; /** * @file The active_theme function * * Docs for TwigExtension::getActiveTheme (Drupal 9.3.x): * * ``` * new TwigFunction('active_theme', [$this, 'getActiveTheme']) * ``` */ const name = 'active_theme'; exports.name = name; const options = {}; exports.options = options; const acceptedArguments = []; /** * Gets the name of the active theme. * * @param {Object<string, ?string|Object<string, ?string>>} config * The shared Drupal config. * * @returns {string} * The name of the active theme. */ exports.acceptedArguments = acceptedArguments; function activeTheme(config) { return config.activeTheme; } /** * Initializes the Drupal active theme config. * * @param {Object<string, ?string|Object<string, ?string>>} state * The shared configuration state object. * @param {Object<string, ?string|Object<string, ?string>>} config * The Drupal config to save. */ function configInit(state, config) { // The default active theme in the Drupal minimal install profile. state.activeTheme = 'stark'; if (Object.prototype.hasOwnProperty.call(config, 'active_theme')) { state.activeTheme = config.active_theme; } }