[Bug] Cannot use `\n` in a template
- Dominant language
- TypeScript
- Stars
- 22.6k
- Forks
- 4.2k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 15
Description
### 🐞 Describe the Bug
Using `"\n"` in an HBS template sends `"\\n"` to the JS code.
### 🔬 Minimal Reproduction
https://github.com/boris-petrov/ember-template-new-line-bug
```typescript
import Helper from '@ember/component/helper';
export default class StringReplace extends Helper {
compute([str, searchValue, replaceValue]) {
console.log(str, searchValue, replaceValue, '\n', '\\n');
return str?.replaceAll(searchValue === '\\n' ? '\n' : searchValue, replaceValue);
}
}
```
```hbs
{{string-replace "asd\nqwe" "\n" "
"}}
```
### 😕 Actual Behavior
Check the console-log. It shows how the value passed to the helper is wrong.
### 🤔 Expected Behavior
The value to be `"\n"` instead of `"\\n"`.
### 🌍 Environment
- Ember: 3.25.3
- Node.js/npm: 15
- OS: Linux
- Browser: Chrome
Contributor guide
Assessment
This issue has not been assessed yet.