You are here

function template_preprocess_quantity in farmOS 2.x

Prepares variables for quantity templates.

Default template: quantity.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing the quantity information and any fields attached to the quantity. Properties used:

  • attributes: HTML attributes for the containing element.

File

modules/core/quantity/quantity.module, line 209
Quantity module.

Code

function template_preprocess_quantity(array &$variables) {
  $variables['quantity'] = $variables['elements']['#quantity'];

  // Helpful $content variable for templates.
  $variables['content'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    if (!empty($variables['elements'][$key]['#items'])) {
      $variables['content'][$key] = $variables['elements'][$key];
    }
  }
}