Is there a way to get the template filename/realpath during generation? I’m using a sort of complicated theme and it would really help if I could embed the filename as a HTML comment during generation.
I realize that within each template/partial, I could always write out the filename - but this is manual and does not work well if you rename the file etc later.
What I’d like to do:
<!-- template: {{ .Template.File}} --> => <!-- /theme/themename/layout/partial/somefile.html -->
and if the template is overridden then of course: <!-- layout/partial/somefile.html -->
I took a shot - it’s ugly with downcasts everywhere but works as expected - though I’m not able to get the top level template (section, home etc). Just putting this here since @zwbetz also found this interesting.
Any pointers on where to find the top level page template?
Thank you… I have a quite a stripped down patch now without any of the ugly downcasts. Also, the root template name _default/single.html etc are now rendered
However, running into a weird error where if the template is ‘alias’ then calling fileAndFilename crashes with a panic on L212 at fi, err := fs.Stat(filename)
I’ve got a check and don’t try to resolve the template file name if it’s alias but would obviously like to understand what’s going on.