nl_tokens: Load a template into the context . The location can either be a string specifiying the remote path to the file a jQuery object or a DOM element . No interpolation happens by default the content is stored in content . In the case of a path unless the option { cache : false } is passed the data is stored in the app s templateCache () . If a jQuery or DOM object is passed the innerHTML of the node is pulled in . This is useful for nesting templates as part of the initial page load wrapped in invisible elements or <script > tags . With template paths the template engine is looked up by the extension . For DOM / jQuery embedded templates this isnt possible so there are a couple of options : * pass an { engine : } option . * define the engine in the data - engine attribute of the passed node . * just store the raw template data and use interpolate () manually If a callback is passed it is executed after the template load .
pl_tokens: function ( location , options , callback ) { var context = this ; return this . then ( function ( ) { var should_cache , cached , is_json , location_array ; if ( _isFunction ( options ) ) { callback = options ; options = { } ; } else { options = $ . extend ( { } , options ) ; } if ( callback ) { this . then ( callback ) ; } if ( typeof location === 'string' ) { // it's a path is_json = ( location . match ( / \.json$ / ) || options . json ) ; should_cache = ( ( is_json && options . cache === true ) || options . cache !== false ) ; context . next_engine = context . event_context . engineFor ( location ) ; delete options . cache ; delete options . json ; if ( <mask> . engine ) { context . next_engine = options . engine ; delete options . engine ; } if ( should_cache && ( cached = this . event_context . app . templateCache ( location ) ) ) { return cached ; } this . wait ( ) ; $ . ajax ( $ . extend ( { url : location , data : { } , dataType : is_json ? 'json' : null , type : 'get' , success : function ( data ) { if ( should_cache ) { context . event_context . app . templateCache ( location , data ) ; } context . next ( data ) ; } } , options ) ) ; return false ; } else { // it's a dom/jQuery if ( location . nodeType ) { return location . innerHTML ; } if ( location . selector ) { // it's a jQuery context . next_engine = location . attr ( 'data-engine' ) ; if ( options . clone === false ) { return location . remove ( ) [ 0 ] . innerHTML . toString ( ) ; } else { return location [ 0 ] . innerHTML . toString ( ) ; } } } } ) ; }