amaterasu

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 common modules that are not templates, since sigil_p is 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 in WebSpanish this 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

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

source code
demo page

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement