When I Dump the values using Debug log I do see the same additional \ char in the string representation. How can I get rid of that additional \ charecter?
My mistake here is that, I typed a simplified code here which will give compiler error for the usage of Double quotes and doesn’t compile. Apologies for that mistake.
Here is one of the simplfied test case. Which passes.
suite : Test
suite =
describe "Helpers Test"
[ test "Testing render" <|
\_ ->
let
t : Attribute msg
t =
title "My title"
h : Dsl.Types.Node msg
h =
h1 [ t ] []
v =
render h
in
Expect.equal v "<h1 title=\"My title\"> </h1> "
]
Here in this image we can see that when debug log is observed all the attributes values have \" instead of "
Debug.log "some message" x prints that x as Elm source code (more or less). Which means that you can copy-paste the output into an Elm file (more or less).
So if x is a String and contains the text abc, then it is going to be printed as "abc". If the string contains quotes, then those are escaped of course (just as when you write code yourself).
But that can be annoying when you’re trying to understand what a string actually looks like. A trick is to “abuse” the message and put the string there instead: Debug.log x (). Here I used the variable I wanted to log (x) as the message, and used () (unit) as the value to log.