Closed basicdays closed 6 years ago
I think I came across a similar issue. The problem, I think, is that if you have some interpolated values that don't have any leading whitespace, that becomes the minimum whitespace. Then, stripIndent
does also include the trim transformer, so the first line gets trimmed of the leading whitespace, but all other lines are untouched.
This is a little surprising to me, because I expected template tags to operate on the template literal before interpolation, rather than not after, but I haven't fully understood how this stuff all works yet.
Aha! In this case, you're actually meant to use the html
tag which does handle embedded newlines.
This tag is also aliased to source
and codeBlock
, which make more sense to me, since personally I'm not writing HTML here.
Hi, I can confirm that the issue is there in v1.4.0. I can't check right now whether it was fixed in #114, but will do so later today. In any case, a version with a fix should be released in a matter of days - keep your fingers crossed 🤞
@ibrahima is right - "fixing" stripIndent
would turn it into source
, so I guess the only thing that's not working here is the naming (one of the unsolved problems of computer science 😉). I'll be adding a note about this particular behavior to the docs.
When I'm including data that was serialized using node's
util.inspect
function,stripIndent
seems to be making some mistakes on how to handle the indent stripping. Here's the script and the output as an example:Actual output:
Expected output: