Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable inside html isn't replaced #225

Open
Zerotask opened this issue Aug 10, 2023 · 1 comment
Open

Variable inside html isn't replaced #225

Zerotask opened this issue Aug 10, 2023 · 1 comment

Comments

@Zerotask
Copy link

Zerotask commented Aug 10, 2023

Describe the bug

{
    "registerHere": "Or <a href='{url}'>register here</a>"
}
<p>{@html $_('registerHere', { values: { url: '/register'}})}</p>

Will produce:

<p>Or <a href="{url}">register here</a></p>

Without the @html it's the same.
If I place the {url} variable outside the html code, it will be replaced correctly.

Expected behavior

<p>Or <a href="/register">register here</a></p>

Information about your project:

  • svelte-i18n version: 3.7.0

  • Whether your project uses Webpack or Rollup: Vite (latest SvelteKit version)

@brunnerh
Copy link

brunnerh commented Sep 3, 2023

The dependency intl-messageformat parses tags, see this section of the docs.

You have to use a very strict format so it does not just throw SyntaxError: INVALID_TAG, i.e. double quotes for attribute values:
'Or <a href="{url}">register here</a>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants