I need some templated markup inside my blazor component.
This is how I'd typically define it (and read it via script):
<script type="text/template" id="foo">
...
</script>
However that gives:
Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. (RZ9992)
How can I suppress RZ9992
just for that one code block?
UPDATE: no that supposed dupe is far more complicated that what I wanted here. People who want a template tag will get the same error, but for a different problem.
CodePudding user response:
Found the answer here.
<script type="text/template" id="foo" suppress-error="BL9992">
...
</script>
But there's an even better way, which according to caniuse is widely supported now:
<template id="foo">
...
</template>
However, note that (probably due to a bug by design) the tag will be empty if it contains a component:
<template id="foo">
<MyComponent />
</template>