How to get the last element in a path?

Solved as follows

{{ $path := "" }}
  {{ with .File }}
        {{ $path = .Path }}
  {{ else }}
        {{ $path = .Path }}
  {{ end }}

{{ path.Base (path.Split $path).Dir }}