Veb & templates #21868
Replies: 2 comments 1 reply
-
Put your HTML files to |
Beta Was this translation helpful? Give feedback.
-
I finally had time to look more at this and the fault was at my end, kind of. When tracing the template rendering, the templates are rendered relative to the first called file which works if rendering an entire page which calls all the @include's. This works well in a traditional web page which is a complete reload of the page. The current trending pattern is to call html partials and swap portions of the page using frameworks such as HTMX and Unpoly. When rendering a complete page the rendering will all be done with the base path being the directory of the root html file, however, if a partial of that page is rendered then the basepath will be the directory containing the partial html file. If both the main page and partial share a component then there will be issues finding the components. As an example In the above folder the index.html file is basically a layout and will @include main.html -> parent.html -> sections/worklist.html -> components/todo.html in that order. This is easy to do as the basepath will be the templates folder so all includes are relative to the root folder However, if sections/worklist was to be rendered itself and updated into the DOM then to include components/todo.html the @include would need to look like The solution? Currently the only way to do this is to ensure all child elements on a page/template are filed in such a way that they are in same directory as the calling template or deeper. This can become difficult to manage when developing a complicated app with many components. I am wondering if there is a better way of enabling calling templates relative to the templates folder? I had a few ideas which i could try to implement and make a PR if it is of interest or if people agree. They should be easy to implement and will not result in any breaking changes
Not sure what peoples thoughts are on these. I would love to try and rebuild a complicated web based app in V but this part is holding me back as I know from past experience that organising the templates folder can become a challenge when sharing components and the only way to build a full app is by reusing small components. |
Beta Was this translation helpful? Give feedback.
-
I am currently experimenting with veb and the templating system but have encountered an issue which I want to ask about before submitting a bug. I am trying to include a component using @include directive but I can not get an error with the path. Is it possible to use the '../' to move up one level in the file path or do all includes need to be in same direction or child directory of the template calling the @include directive?
results in below
Beta Was this translation helpful? Give feedback.
All reactions