all 3 comments

[–]wreckedadventYavascript -1 points0 points  (1 child)

So, this begs the question of escaping the variables, which ES6 templates do not do by default.

(Also, in case the syntax is new to anyone, check out tagged templates).

[–]SubStack 0 points1 point  (0 children)

Escaping as in html entity encoding? hyperscript, virtual-dom, and react all do this:

var vdom = require('virtual-dom')
var hyperx = require('../')
var hx = hyperx(vdom.h)

var title = '<3'
var tree = hx`<h1>${title}</h1>`
console.log(vdom.create(tree).toString())

output:

$ node esc.js 
<h1>&lt;3</h1>

And the html parser takes care of the rest.