Render html tags with component interpolation
See original GitHub issueIt’s possible to render html tags with component interpolation?
Example:
const messages = {
en: {
text: '<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.</p><p>Lorem ipsum, dolor {email}.</p>',
email: 'foo@acme.com'
}
}
<i18n path="text" tag="div">
<my-link place="email" :href="`mailto:$t('email')`">{{ $t('args.email') }}</my-link>
</i18n>
I expect two paragraphs, and in the second paragraph, one link with my custom link component, but, the paragraphs was rendering as strings and not as html tags.
Maybe it’s is a bug? Or is impossible to render an html tags inside a <i18n> component?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:14
Top Results From Across the Web
How to give html tags inside string interpolation in reactjs?
You can do something like this: const confirmMessage = isDelete ? ( <p> You are about to delete the <em>{valueType}</em>.
Read more >Render html tags with component interpolation #898 - Issuehunt
It's possible to render html tags with component interpolation? Example: const messages = { en: { text: '<p>Lorem ipsum, dolor sit amet consectetur ......
Read more >JSX In Depth - React
The first part of a JSX tag determines the type of the React element. Capitalized types indicate that the JSX tag is referring...
Read more >Angular — How to render HTML containing ... - Talentica
The dynamic components rendering factory · Find Components' HTML elements in DOM (of the dynamic HTML). · Create appropriate Angular Components ...
Read more >Writing templates - Lit.dev
The html tag function returns a TemplateResult —a lightweight object that represents the template to be rendered. The render function actually creates DOM ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In general I agree with that statement. But I think there are still some use-cases where html in the translations makes sense, like if you want to highlight 1 word by using a
<b>
tag, or like the use-case of @leandromatos-hotmart. Would it make sense to add something like aisHtml
option to the i18n tag?I like to add my vote to enable HTML be output as such inside interpolation from
<i18n-t>
. Translated languages can have different grammar and different phrase symbols (think Quotes, Ampersand) which requires multiple paragraphs in the translation or HTML escapes.As such, for a translation utility, I think this is a 1st class requirement.
I also like to know what the security issue is exactly. Translations are static pre-delivered and not user-generated for other users on the fly. Sanitisation would have to occur on borders, ie. first after a backend received data, not “inbetween every code line”.