1. Caddy version (caddy version
):
2.3.0
2. How I run Caddy:
docker
a. System environment:
Docker
b. Command:
default
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
{
order cgi last
}
(shared) {
log
encode gzip
tls internal
}
dev.localhost {
import shared
cgi /*.py /usr/bin/python3 /usr/local/cgi/{path}
file_server / {
root /var/www
browse /var/browse.html
}
}
<table>
{{- range .Items}}
<tr class="file">
<td>{{if hasSuffix .Name ".dev"}}YES{{end}}</td>
<td>
<a href="{{html .URL}}">
{{- if .IsDir}}
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder{{if .IsSymlink}}-shortcut{{end}}"></use></svg>
{{- else}}
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 265 323"><use xlink:href="#file{{if .IsSymlink}}-shortcut{{end}}"></use></svg>
{{- end}}
<span class="name">{{html .Name}}</span>
</a>
</td>
{{- if .IsDir}}
<td data-order="-1">—</td>
{{- else}}
<td data-order="{{.Size}}">{{.HumanSize}}</td>
{{- end}}
<td class="hideable"><time datetime="{{.HumanModTime "2006-01-02T15:04:05Z"}}">{{.HumanModTime "01/02/2006 03:04:05 PM -07:00"}}</time></td>
<td class="hideable"></td>
</tr>
{{- end}}
</table>
3. The problem I’m having:
In Caddy documentation it says “All Sprig functions are supported.”
The template is copied from Caddy default browse template.
Only changed the first td
to try out hasSuffix
from sprig.
I get an error on start.
4. Error messages and/or full log output:
run: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler
modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 1: loading handler modules: position 0: loading module 'file_server': provision http.handlers.file_server: parsing browse template file: template: browse.html:4: function "hasSuffix" not defined
5. What I already tried:
Not much. First time trying to use go template.