In a custom element template, assume a string such as hello\world
stored as this.foo
.
How may I replace \n
by <br />
?
Several posts found on SE mention Juicy (https://github.com/Juicy/juicy-html) Others use a custom element as a wrapper (see Bind text with line breaks)
But isn't there a more straightforward method, what about doing something like:
<template is="dom-repeat" items="{{bubbles}}">
<li><span class="content">{{getContent(item)}}</span></li>
</template>
And
getContent: function(item) {
return item.content.replace(/\\n/g, "<br />")
}
Problem is that the <br />
isn't evaluated as an HTML element
So isn't there a proper way to validate a string against certain allowed tags (br
in this case), or must I really go the Juicy way ?
What do you think ? ;)