Remove space at the end of node after using ~e sigil

Hi, I’m using ~e sigil to generate an html code. By default, it adds “\n” at the end of a node, but I want to remove this space. Is there a way to do it (instead of manual removing, mean I can just split the string and remove the last item in the list, and then join again)?

Here is example:

~e""" 
    <span class="my-class"></span> 
"""

Result:
{:safe, ["<span class=\"my-class\"></span>\n"]}

Thanks in advance!

Your here doc has to end with a \ to remove \n.

iex(1)> """
...(1)> asdf\
...(1)> """
"asdf"
3 Likes

thanks!