This applies to Craft 2. For Craft 3+, see [hashchange's answer][1].

----------

You can get the current template’s name like so:

    {{ _self.getTemplateName() }}


  [1]: https://craftcms.stackexchange.com/a/27606/4748