Open tunnckoCore opened 9 years ago
And again, if you want to provide also the html (DOM-like, as currently) you can just return object from .renderSync
that returns {document: doc, result: compiledHtmlString}
and in .render()
you can follow that signature
var doc = cheerio.load(htmlString)
var result = tcl.render(doc, data, function (err, result, doc) {
console.log(doc.html()) // as now
console.log(result) //=> the compiled html string
// <div id="someElement">
// <h1 data-tlc="bind $var '.message'; apply --append;">Hello World</h1>
//</div>
})
But it would be better getting DOM to be with different method to not mess up the render*
methods with bloat stuff.
Also you dont need cheerio
and multiline
in the dependencies
field.
Or even, it would be better to force to just pass html string, and you to use cheerio
, without so many variants for incoming input - just to be string is enough.
Hi!
It looks good, currently. But that
isn't correct way. Expose api to retrieve the result synchronously or pass it in callback.
E.g.
or callback