Open tschuehly opened 2 months ago
I personally don't really like having constants for the URL paths. I don't feel it improves the readability of the code as the function of a controller method is mapping a URL to a method, so I like to have my URL close to my method. Some might call it locality of behaviour ;-)
But if others feel this is useful, we could add this.
In a big project, it really helps finding where Controller Endpoints are used. Especially as you can browse around with CTRL + B between your templates and your Controllers in IntelliJ.
The constants are separate from the HtmxUtils discussion. I would expose the utils class as a bean then reference it via @util.uri()
syntax. (That references Spring beans)
However, I haven't found a consistent use for it. So I would be interested to see the proposed methods.
The constants are separate from the HtmxUtils discussion. I would expose the utils class as a bean then reference it via
@util.uri()
syntax. (That references Spring beans)
Once again, I would stay with a complete static Util Class as we can use it with all template langauges
However, I haven't found a consistent use for it. So I would be interested to see the proposed methods.
I will clean one up and post it here,
I would love to see this utils, it make sense to me.
In every project I'm doing I create a HtmxUtil class, I think this improves template readability, and could start establishing good practices.
For example having a URI method to put variables into a constant:
and then in the controller
then in the template
Here's an example: https://github.com/tschuehly/htmx-spring-workshop/blob/lab-4/src/main/java/de/tschuehly/easy/spring/auth/htmx/HtmxUtil.java