-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL extension uses Route::get() ? maybe URL::site() is better? #3
Comments
apologies if I'm just misunderstanding what the url extension should do. possibly you could drop this in favor of the helper extension, which allows url.site (I think?) |
Route::get() works just fine for me. How are you using the tag?
For example to load the edit action on the posts controller you would use the following:
Hope that helps? Cheers, Aron |
I see, thanks. Should that tag be called "route" then? Since it relates directly to the Route helper, that makes more sense to me anyway. I was using this tag, trying to link to a static asset e.g. {% url '/img/foo.png' %} or, in general, I find it easier, simpler, clearer to just use URL format (especially if the template coders are not backend devs, and shouldn't need to know controller, action, etc) e.g. |
Ideally you should be able to rename the tags by simply creating your own For your static assets you could either create a tag module for the URL class or a simpler solutions would be to define a "base_url" variable in your controller set to
I'd argue that you should always use the controllers and actions in your views even if it does make them appear more complex as it decouples the site URLs from the templates. This means that in the future should you decide to modify your applications routes, for example adding a prefix or swapping the parameters around, all your templates will still generate correct links and not require any modification. Cheers, Aron |
Route::get() doesn't work for me, would URL::site() be better? Maybe I'm not using it correctly?
I'm on K03.
The text was updated successfully, but these errors were encountered: