Reputation: 89
I'm currently trying to generate the file api.ex
from template.exs
.
I have a function that returns a string value of "name"
but I want it to be printed into the api.ex as only name
I already tried:
String.replace(~s("name"), ~s("), "")
The code that returns my still quoted string is:
<%= inspect type |> Inflex.underscore |> erase_quotes %>
Upvotes: 0
Views: 56
Reputation: 222108
The issue is of the precedence of function calls and pipes.
inspect x |> f
is the same as inspect(x |> f)
, not inspect(x) |> f
.
This should work:
<%= inspect(type) |> Inflex.underscore |> erase_quotes %>
but.. the reason you're getting the double quotes in the first place is that you're using inspect
which adds those. Removing the call to inspect
will remove the quotes. The following should work:
<%= type |> Inflex.underscore %>
Upvotes: 1