function render (obj, def, html) {
  var i, nodes, handler, parser, element, elementPrototype

  // If given bindings with a root node, pick only the binding keys.
  if (Array.isArray(def)) def = def[1]

  // Generating the render function is processing intensive. Skip if possible.
  if (renderFnKey in def) return def[renderFnKey](obj)

  // Callback API looks weird. This is actually synchronous, not asynchronous.
  handler = new htmlParser.DomHandler(function (error, result) {
    if (error) throw error
    nodes = result
  }, handlerOptions)

  parser = new htmlParser.Parser(handler)
  parser.write(html)
  parser.end()

  for (i = nodes.length; i--;)
    if (nodes[i].type === 'tag') {
      element = nodes[i]
      break
    }

  if (!element) throw new Error('No element found!')

  elementPrototype = Object.getPrototypeOf(element)
  Element.prototype = elementPrototype
  Object.defineProperties(elementPrototype, elementExtension)

  processDefinition(def, nodes)
  def[renderFnKey] = makeRender(def, nodes)

  return def[renderFnKey](obj)
}
function render (obj, def, html) {
  var i, nodes, handler, parser, element, elementPrototype

  // If given bindings with a root node, pick only the binding keys.
  if (Array.isArray(def)) def = def[1]

  // Generating the render function is processing intensive. Skip if possible.
  if (renderFnKey in def) return def[renderFnKey](obj)

  // Callback API looks weird. This is actually synchronous, not asynchronous.
  handler = new htmlParser.DomHandler(function (error, result) {
    if (error) throw error
    nodes = result
  }, handlerOptions)

  parser = new htmlParser.Parser(handler)
  parser.write(html)
  parser.end()

  for (i = nodes.length; i--;)
    if (nodes[i].type === 'tag') {
      element = nodes[i]
      break
    }

  if (!element) throw new Error('No element found!')

  elementPrototype = Object.getPrototypeOf(element)
  Element.prototype = elementPrototype
  Object.defineProperties(elementPrototype, elementExtension)

  processDefinition(def, nodes)
  def[renderFnKey] = makeRender(def, nodes)

  return def[renderFnKey](obj)
}
function render ( obj , def , html ) { var i , nodes , handler , parser , element , elementPrototype // If given bindings with a root node, pick only the binding keys. if ( Array . isArray ( def ) ) def = def [ 1 ] // Generating the render function is processing intensive. Skip if possible. if ( renderFnKey in def ) return def [ renderFnKey ] ( obj ) // Callback API looks weird. This is actually synchronous, not asynchronous. handler = new htmlParser . DomHandler ( function ( error , result ) { if ( error ) throw error nodes = result } , handlerOptions ) parser = new htmlParser . Parser ( handler ) parser . write ( html ) parser . end ( ) for ( i = nodes . length ; i -- ; ) if ( nodes [ i ] . type === 'tag' ) { element = nodes [ i ] break } if ( ! element ) throw new Error ( 'No element found!' ) elementPrototype = Object . getPrototypeOf ( element ) Element . prototype = elementPrototype Object . defineProperties ( elementPrototype , elementExtension ) processDefinition ( def , nodes ) def [ renderFnKey ] = makeRender ( def , nodes ) return def [ renderFnKey ] ( obj ) }
Internal function for rendering strings. The benchmark to beat is plain old
string concatenation and for loops. Although this won't be faster, it should
work with more or less the same functionality as the DOM version.

Only a tiny subset of the actual DOM is implemented here, so it may not work
for all front-end functionality.

@param {Object} obj
@param {Object} def
@param {String} [html]
@return {String}
Internal function for rendering strings . The benchmark to beat is plain old string concatenation and for loops . Although this won t be faster it should work with more or less the same functionality as the DOM version .