Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow `file_server browse` templates to use the same functions as `templates` #3637
Comments
|
Hi, new contributor here |
|
Cool! Go for it @divbhasin |
|
Here is what I am thinking: I need to make the Am I on the right track @francislavoie? |
|
Yeah, that sounds about right. Maybe the |
|
Hmm, this is tricky though because in order to support of all of This will need more consideration/discussion; I think there'll need to be some sort of new function or method that is exported to wrap all the unexported logic needed for this, without having to create a whole HTTP handler or something. |
|
@mholt yeah I have been struggling with how to incorporate the Templates type into browse. |
See the discussion here: https://caddy.community/t/v2-http-handlers-templates-functions-in-file-server-browse-template/9214
The
file_serverdirective has abrowseoption which enables a directory index to be served when a directory is requested. By default, this index is rendered using a template which can be found in the code. The default can be overridden with a template provided by the user.It seems that the
file_server browsetemplate doesn't use the same code paths as thetemplatesdirective, which means that the functions documented here cannot also be used.The code should be refactored such that the logic for the templates is shared between these two such that all the template functions Caddy provides works both for the general templates and for the file server directory index.