Replies: 1 comment 1 reply
-
You can also write this: const example = ['hello', 'world'];
<template>
{{example}}
</template> And render this:
The reason we prohibit both of those cases isn't that you'll get a runtime exception when trying to render the value, it's that values of those types don't typically represent user-consumable information. 9 times out of 10 if we encounter a symbol or object being used directly as template content, it represents a typo or refactoring mistake like accidentally referencing source data instead of the human-formatted version. TS's types for native language features are full of similar cases to this—the For cases where you do want to coerce an arbitrary value to a string no matter what it is, you can either coerce it in TS and reference the result in the template, or use the import { concat } from '@ember/helper';
const example = Symbol('example');
const exampleString = example.toString();
// Both of these will render `Symbol(example)` with no type error:
<template>
{{exampleString}}
{{concat example}}
</template> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Interested to hear thoughts about this.
Will render
Beta Was this translation helpful? Give feedback.
All reactions