Skip to content

Conversation

@tylerturdenpants
Copy link
Collaborator

fixes #219

test('string-mixed-line-endings', () => {
let input = '{{foo-bar placeholder="Choose a... \\t\\r\\n"}}';

expect(runTest('string-mixed-line-endings.hbs', input)).toMatch(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Turbo87 I had to change to toMatch from toMatchInlineSnapshot because toMatchInlineSnapshot runs prettier not allowing me to express the string correctly for the test. I

@tylerturdenpants tylerturdenpants added the bug Something isn't working label Dec 31, 2019

if (_value.chars && _value.chars.length > 0) {
_value.chars = JSON.stringify(_value.chars).slice(1, -1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. What are we stringifying something here?

Copy link
Collaborator Author

@tylerturdenpants tylerturdenpants Jan 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason i do this is because _value has the \ stripped within the string:
image

hence:"Choose a "thing"..."
JSON.stringify is great at escaping strings. So I use it to properly escape strings and remove the first and last double-quote resulting in Choose a \"thing\"...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that a bug in the printer or template-recast?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t consider that. I guess I could check how other parsers handle such things. I’ll look into this a little more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrites escaped quotes to quotes (causing Template Compiler Error)

3 participants