public function TwigFormulaLoader::load

Loads formulae from a resource.

Formulae should be loaded the same regardless of the current debug mode. Debug considerations should happen downstream.

Parameters

ResourceInterface $resource A resource:

Return value

array An array of formulae

Overrides FormulaLoaderInterface::load

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/TwigFormulaLoader.php, line 31

Class

TwigFormulaLoader
Loads asset formulae from Twig templates.

Namespace

Assetic\Extension\Twig

Code

public function load(ResourceInterface $resource) {
  try {
    $tokens = $this->twig
      ->tokenize($resource
      ->getContent(), (string) $resource);
    $nodes = $this->twig
      ->parse($tokens);
  } catch (\Exception $e) {
    return array();
  }
  return $this
    ->loadNode($nodes);
}