Because of how POSIX defines a line some people consider it ‘good practice’ to have a newline at the end of a file. Many editors are set up to do this automatically.
However the Phoenix render function (using EEX) does not ignore this newline character which can result in unexpected/inconvenient behaviour such as the following:
# _text.html.eex (with a newline at end to make it a valid POSIX line)
@text
iex(1)> Phoenix.View.render(PageView, "_text.html", text: "text")
{:safe, ["" | "@text\n"]}
Note the newline at the end. This causes issues when rendering multiple templates next to each other and you don’t want newlines/spaces inserted.
Would you consider this a bug? If not, is there a workaround (other than removing the newline at the end of the file)?
Thanks.