I'm currently experimenting with LitElement which uses lit-html. lit-html would like the content to be provided as such:
html`Content goes here ${variable} <button on-click="${(e) => myEvent()}"`
I am able to import the template using raw-loader, html-loader, even es6-template-string-loader. I'm unable to provide this to the HTML function in the right format.
html is a function than takes an array of strings and values. Using the tagged syntax takes care of the splitting of the strings and the variables for you.
My question is, how could I dynamically provide the html function the imported template, or how would I take care of the splitting of the template myself?
Edit: Just to be clear I'm not trying to convert a string to a template literal. I am trying to provide a template literal to a tagged function dynamically. Using the
tag`${templateLiteral}`
syntax stores the content in one variable, and will not work. Using the
tag(templateLiteral)
syntax is not correct, because the tag function expects tag(array of strings, ...values).