Getting the Template Name

I sometimes need more control over the styling than conventional ID’s and classes can provide; which will also protect against user input and be dynamic. I like to use a combination of the root alias, parent alias (if not the same as root) and the template name. The reason for this is so I can have full control over what gets styled and how even if the user doesn’t include that...