I am looking for built in function something like String builder with Placeholders.
Iet say in C like languages usuall you wold have function that looks like:
print(" Some string %placeholder1, string continues…%placeholder2", var1, var2) #vars goes to placeholders
`Do we have something similar in Elixir ?
Use Case:
User provides: custom url with placeholders and separately details.
Then later url should be combined with data into proper url.
The point is that this solution is not flexible…
This would work good on static urls, that do not change…
In cases where url can be any, probably it is better to use cpgo’s solution.
In my case I cant know in advance all possible urls, but I can tell user use the fallowing layout… and the test if user provides url according to layout and if it is matches then execute as a template…
You should generally be using the URI module to deal with URLs: https://hexdocs.pm/elixir/URI.html
That will handle the escaping, otherwise you will have plenty of surprises with strange data.
Thank you for advice :+1 , but I probably had to mentioned that I would prefer not to add extra dependencies. Meanwhile, I can have a look, into their code and analyse it to get more ideas.
Format is rather experimental right now and has some issues especially around formatting floats. Maybe I should finally get into it an finish it, now that Jason is mostly done