leaf-kit icon indicating copy to clipboard operation
leaf-kit copied to clipboard

Add a `#routes` or `#link_to` Tag

Open thecodechef opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. I'm currently looking for a way to add my routes in my leaf templates

<a href="#routes(home)">Home</a>
# => <a href="/home">Home</a>

Describe the solution you'd like I would like for a way to add routes to leaf templates

Describe alternatives you've considered thought about hardcoding them but that is too tedious and it doesn't scale very well

Additional context As an Example here is a Rails

<%= link_to "Home", @home %>
# => <a href="/home">Home</a>

thecodechef avatar Jan 13 '23 04:01 thecodechef

@natebird @tonyarnold @ts @shnhrrsn Just wanting to know if there is anyway for this in the future

thecodechef avatar Jan 22 '23 02:01 thecodechef

+1 for this, in fact it feels like quite a blind spot in Vapor's type safety, the fact that URLs are all produced with string concatenation. Having a URL builder interface to the router, that is validated as much as possible, and then exposed in Leaf templates, would be really nice. Even in a small Vapor application I've wanted this quite a few times.

I'll probably end up writing something for this myself, if it becomes generically applicable then I'll try and contribute it or at least get a gist up somewhere.

danpalmer avatar Jul 16 '23 15:07 danpalmer