amaterasu
Named routes with sigil_p
I have an umbrella project with N apps, all with the same web structure, but different db and possibly language.
Since the templates are all the same, I thought of creating a common app and I’m using templates like this:
defmodule WebEnglish.CategoryHTML do
use WebEnglish, :html
embed_templates "category_html/*", root: Common.Templates.root()
end
...
defmodule WebSpanish.CategoryHTML do
use WebSpanish, :html
embed_templates "category_html/*", root: Common.Templates.root()
end
I’m now having two issues:
- I can’t use verified routes from
commonmodules that are not templates, sincesigil_pis not available there. - I can use verified routes in templates within
common, but what if I need routes in another language/format? ex.~p"/categories"works, but inWebSpanishthis should be~p"/categorias".
I’m looking at localized routes, but this wouldn’t work either because my understanding is that both categories and categorias would be valid routes in both my web apps.
So I kind of need Router Helpers again, but I know it’s deprecated and I’m looking for an alternative.
What do you think? Thanks!
Marked As Solved
BartOtten
After reading the thread I am not sure I understand but let’s kick the can…
I think you don’t necessarily want helpers back but want to be able to write a path in your templates which translates during runtime to an URL depending on certain criteria.
Have a look at GitHub - BartOtten/routex: Build powerful Phoenix routes: localize, customize, and innovate · GitHub. Unlike native verified routes, Routex Verified Routes does support branching. As Routex is extension based, I am quite sure there is a combination of extension which will support your use case.
Demonstration
of single path in template with variable path during runtime
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









