Skip to content

Instantly share code, notes, and snippets.

@camoa
Last active June 26, 2020 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save camoa/4561530b69243738da6dafa8ad0ddfe5 to your computer and use it in GitHub Desktop.
Save camoa/4561530b69243738da6dafa8ad0ddfe5 to your computer and use it in GitHub Desktop.
D728: Task-24 Define a custom template for module output
<p> This is the lotus template with a value of {{ test_var }} </p>
/**
* Implements hook_theme() to add the template definition.
**/
function lotus_theme($existing, $type, $theme, $path) {
return array(
'lotus_template' => array(
'variables' => array('test_var' => NULL),
),
);
}
/**
* @file
* Contains \Drupal\lotus\Controller\LotusController.
*/
namespace Drupal\lotus\Controller;
use Drupal\Core\Controller\ControllerBase;
class LotusController extends ControllerBase {
public function content() {
return array(
'#theme' => 'lotus_template',
'#test_var' => $this->t('Test Value'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment