OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

HTMLGlob template pattern matching with nested subdirectories

  • Thread starter Thread starter ancient geek
  • Start date Start date
A

ancient geek

Guest
I am working on a golang project using gin and go templating. My templates are in a structure like so:

Code:
C:.
├───components
├───display
....

I would like to add subdirectories to organise the templates, like so:

Code:
C:.
├───components
│   └───tables
├───display
...

I use gin's HTMLglob to load the templates like so:

Code:
r.LoadHTMLGlob("./templates/*/*")

or alternatively

Code:
r.LoadHTMLGlob("./templates/**/*")

(the second version was recommended in a couple of templating examples, so I tried it)

The template names are all different so there is no issue of name duplication. I'm just trying to store them in a directory/subdirectory structure that makes them easier to locate.

However, when I introduce the tables subdirectory, the compiler gives me the following error:

Code:
panic: read templates\components\tables: Incorrect function.

I'm relatively unfamiliar with the globstar pattern matching which I believe is used by HTMLglob, but I don't quite see why recursing into a sub-sub-directory should cause an error.

It doesn't make any difference whether tables contains a template file or not.

I'd welcome any solution that lets me organise my templates in subdirectories
Continue reading...
 

Latest posts

ن
Replies
0
Views
1
نعمان منذر محمود الجميلي
ن
Top