js_example.module

Same filename in other branches
  1. 7.x-1.x js_example/js_example.module
  2. 4.0.x modules/js_example/js_example.module

Examples showing how to use some of the new JavaScript features in Drupal 8.

File

modules/js_example/js_example.module

View source
<?php


/**
 * @file
 * Examples showing how to use some of the new JavaScript features in Drupal 8.
 */

/**
 * @defgroup js_example Example: JavaScript
 * @ingroup examples
 * @{
 * Examples using Drupal 8's built-in JavaScript.
 *
 * We have two examples here.
 *
 * One 'weights' content and then sorts it by weight. This demonstrates
 * attaching JavaScript through Drupal's render arrays.
 *
 * The other demonstrates adding an accordion effect to content, through
 * Drupal's theme layer.
 */

/**
 * Implements hook_theme().
 */
function js_example_theme() {
    return [
        'js_example_accordion' => [
            'template' => 'accordion',
            'variables' => [
                'title' => NULL,
            ],
        ],
    ];
}

/**
 * @} End of "defgroup js_example".
 */

Functions

Title Deprecated Summary
js_example_theme Implements hook_theme().