EEx typespec
Closed this issue · 2 comments
LostKobrakai commented
Elixir and Erlang/OTP versions
Elixir 1.18.4
Operating system
Mac OS X
Current behavior
EEx.compile_string is spec'ed to return String.t, but eex engines to not seem to need to adhere to that result. E.g. Phoenix.HTML.Engine returns safe tuples.
Expected behavior
At this point it's probably unavoidable to officially extend the interface here, but I'm wondering it EEx engines would be expected to return just strings or plain any datastructure. I'm looking into builing up something similar like Phoenix.HTML.Engine + the safe protocol.
josevalim commented
Can you please provide more information? Because this is what I'm looking at:
@spec compile_string(String.t(), [compile_opt]) :: Macro.t()
Perhaps you mean something else?
LostKobrakai commented
Ah sorry. EEx.eval_string, not compile_string
import Phoenix.HTML
EEx.eval_string("""
Abcl <%= @test %>
""", [assigns: %{test: "Hi"}], engine: Phoenix.HTML.Engine)
# {:safe, ["Abcl ", "Hi", "\n"]}