Skip to content

Instantly share code, notes, and snippets.

@lkacenja
Created October 21, 2016 16:39
Show Gist options
  • Save lkacenja/d239b595e44cc946a043cd54c5d056a0 to your computer and use it in GitHub Desktop.
Save lkacenja/d239b595e44cc946a043cd54c5d056a0 to your computer and use it in GitHub Desktop.
<?php
$route_name = \Drupal::routeMatch()->getRouteName();
$bits = explode('.', $route_name);
for ($i = 0; $i < count($bits); $i ++) {
if ($i == 0) {
$body_classes[] = str_replace('_', '-', $bits[$i]);
}
else {
$body_classes[] = str_replace('_', '-', $bits[$i - 1] . '-' . $bits[$i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment