You are here

function angularjs_page_alter in AngularJS 7

Implements hook_page_alter

Adds partials to the page footer

Parameters

array $variables :

File

./angularjs.module, line 627

Code

function angularjs_page_alter(&$variables) {
  $partials = angularjs_add_partial();
  drupal_alter('angularjs_partials', $partials);
  foreach ($partials as $name => $output) {

    // If we have a render array render it
    if (TRUE === is_array($output)) {
      $output = render($output);
    }
    $element = array(
      '#tag' => 'script',
      '#value' => $output,
      '#attributes' => array(
        'type' => 'text/ng-template',
        'id' => $name,
      ),
    );
    $variables['footer']['partial_' . $name] = array(
      '#markup' => theme('html_tag', array(
        'element' => $element,
      )),
    );
  }
}