Hello!
First of all, I apologize if this is not the right place to ask about this problem. I’ve just got started with Elixir and so far it’s been a pleasure!
I’m trying to use Expug as a templating engine for my new Phoenix project.
I’m using Phoenix 1.4.10, Elixir 1.9.0, Erlang 22. Tested on Ubuntu 19.04 and Arch Linux.
When I try to use accented characters in attribute values, e.g. button(title="helló") world
(‘ó’ in this case), I get this error:
Compiling 1 file (.ex)
== Compilation error in file lib/hello_web/views/page_view.ex ==
** (UnicodeConversionError) invalid encoding starting at <<195, 34, 41, 41, 32, 37, 62, 62, 60, 37, 61, 32, 34, 92, 110, 34, 32, 37, 62, 104, 101, 108, 108, 111, 60, 37, 61, 32, 34, 92, 110, 34, 32, 37, 62, 60, 47, 112, 62, 10>>
(elixir) lib/string.ex:2180: String.to_charlist/1
(eex) lib/eex/tokenizer.ex:33: EEx.Tokenizer.tokenize/3
(eex) lib/eex/compiler.ex:18: EEx.Compiler.compile/2
(phoenix) lib/phoenix/template.ex:354: Phoenix.Template.compile/3
(phoenix) lib/phoenix/template.ex:165: anonymous fn/4 in Phoenix.Template."MACRO-__before_compile__"/2
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) expanding macro: Phoenix.Template.__before_compile__/1
lib/hello_web/views/page_view.ex:1: HelloWeb.PageView (module)
(elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
The very same character works elsewhere (i.e. outside attribute values), and it also works in EEx templates, so I guess it’s a bug in Expug.
I don’t mind getting my hands dirty to fix this myself; I just need some directions. I guess it’s just a matter of fixing the encoding somewhere between Expug’s stringifier and EEx’s parser, but I still don’t understand much about Elixir or EEx’s internals so I’m not sure and can’t find the culprit.
Thanks in advance!