nl_tokens: 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 .
pl_tokens: 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 = <mask> } , 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 ) }