boiler/attachments/sammy/plugins/sammy.pure.js
function compiler(dom, directive, data, ans){
    var fns = [];
    // autoRendering nodes parsing -> auto-nodes
    ans = ans || data && getAutoNodes(dom, data);
    if(data){
      var j, jj, cspec, n, target, nodes, itersel, node, inner;
      // for each auto-nodes
      while(ans.length > 0){
        cspec = ans[0].cspec;
        n = ans[0].n;
        ans.splice(0, 1);
        if(cspec.t === 'str'){
          // if the target is a value
          target = gettarget(n, cspec, false);
          setsig(target, fns.length);
          fns[fns.length] = wrapquote(target.quotefn, dataselectfn(cspec.prop));
        }else{
          // if the target is a loop
          itersel = dataselectfn(cspec.sel);
          target = gettarget(n, cspec, true);
          nodes = target.nodes;
          for(j = 0, jj = nodes.length; j < jj; j++){
            node = nodes[j];
            inner = compiler(node, false, data, ans);
            fns[fns.length] = wrapquote(target.quotefn, loopfn(cspec.sel, itersel, inner));
            target.nodes = [node];
            setsig(target, fns.length - 1);
          }
        }
      }
    }
    // read directives
    var target, dsel;
    for(var sel in directive){
      if(directive.hasOwnProperty(sel)){
        dsel = directive[sel];
        if(typeof(dsel) === 'function' || typeof(dsel) === 'string'){
          // set the value for the node/attr
          target = gettarget(dom, sel, false);
          setsig(target, fns.length);
          fns[fns.length] = wrapquote(target.quotefn, dataselectfn(dsel));
        }else{
          // loop on node
          loopgen(dom, sel, dsel, fns);
        }
      }
    }
        // convert node to a string
        var h = outerHTML(dom), pfns = [];
    // IE adds an unremovable "selected, value" attribute
    // hard replace while waiting for a better solution
        h = h.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig, "<$1 $3>");

        // remove attribute prefix
        h = h.split(attPfx).join('');

    // slice the html string at "Sig"
    var parts = h.split( Sig ), p;
    // for each slice add the return string of
    for(var i = 1; i < parts.length; i++){
      p = parts[i];
      // part is of the form "fn-number:..." as placed there by setsig.
      pfns[i] = fns[ parseInt(p, 10) ];
      parts[i] = p.substring( p.indexOf(':') + 1 );
    }
    return concatenator(parts, pfns);
  }
function compiler(dom, directive, data, ans){
    var fns = [];
    // autoRendering nodes parsing -> auto-nodes
    ans = ans || data && getAutoNodes(dom, data);
    if(data){
      var j, jj, cspec, n, target, nodes, itersel, node, inner;
      // for each auto-nodes
      while(ans.length > 0){
        cspec = ans[0].cspec;
        n = ans[0].n;
        ans.splice(0, 1);
        if(cspec.t === 'str'){
          // if the target is a value
          target = gettarget(n, cspec, false);
          setsig(target, fns.length);
          fns[fns.length] = wrapquote(target.quotefn, dataselectfn(cspec.prop));
        }else{
          // if the target is a loop
          itersel = dataselectfn(cspec.sel);
          target = gettarget(n, cspec, true);
          nodes = target.nodes;
          for(j = 0, jj = nodes.length; j < jj; j++){
            node = nodes[j];
            inner = compiler(node, false, data, ans);
            fns[fns.length] = wrapquote(target.quotefn, loopfn(cspec.sel, itersel, inner));
            target.nodes = [node];
            setsig(target, fns.length - 1);
          }
        }
      }
    }
    // read directives
    var target, dsel;
    for(var sel in directive){
      if(directive.hasOwnProperty(sel)){
        dsel = directive[sel];
        if(typeof(dsel) === 'function' || typeof(dsel) === 'string'){
          // set the value for the node/attr
          target = gettarget(dom, sel, false);
          setsig(target, fns.length);
          fns[fns.length] = wrapquote(target.quotefn, dataselectfn(dsel));
        }else{
          // loop on node
          loopgen(dom, sel, dsel, fns);
        }
      }
    }
        // convert node to a string
        var h = outerHTML(dom), pfns = [];
    // IE adds an unremovable "selected, value" attribute
    // hard replace while waiting for a better solution
        h = h.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig, "<$1 $3>");

        // remove attribute prefix
        h = h.split(attPfx).join('');

    // slice the html string at "Sig"
    var parts = h.split( Sig ), p;
    // for each slice add the return string of
    for(var i = 1; i < parts.length; i++){
      p = parts[i];
      // part is of the form "fn-number:..." as placed there by setsig.
      pfns[i] = fns[ parseInt(p, 10) ];
      parts[i] = p.substring( p.indexOf(':') + 1 );
    }
    return concatenator(parts, pfns);
  }
function compiler ( dom , directive , data , ans ) { var fns = [ ] ; // autoRendering nodes parsing -> auto-nodes ans = ans || data && getAutoNodes ( dom , data ) ; if ( data ) { var j , jj , cspec , n , target , nodes , itersel , node , inner ; // for each auto-nodes while ( ans . length > 0 ) { cspec = ans [ 0 ] . cspec ; n = ans [ 0 ] . n ; ans . splice ( 0 , 1 ) ; if ( cspec . t === 'str' ) { // if the target is a value target = gettarget ( n , cspec , false ) ; setsig ( target , fns . length ) ; fns [ fns . length ] = wrapquote ( target . quotefn , dataselectfn ( cspec . prop ) ) ; } else { // if the target is a loop itersel = dataselectfn ( cspec . sel ) ; target = gettarget ( n , cspec , true ) ; nodes = target . nodes ; for ( j = 0 , jj = nodes . length ; j < jj ; j ++ ) { node = nodes [ j ] ; inner = compiler ( node , false , data , ans ) ; fns [ fns . length ] = wrapquote ( target . quotefn , loopfn ( cspec . sel , itersel , inner ) ) ; target . nodes = [ node ] ; setsig ( target , fns . length - 1 ) ; } } } } // read directives var target , dsel ; for ( var sel in directive ) { if ( directive . hasOwnProperty ( sel ) ) { dsel = directive [ sel ] ; if ( typeof ( dsel ) === 'function' || typeof ( dsel ) === 'string' ) { // set the value for the node/attr target = gettarget ( dom , sel , false ) ; setsig ( target , fns . length ) ; fns [ fns . length ] = wrapquote ( target . quotefn , dataselectfn ( dsel ) ) ; } else { // loop on node loopgen ( dom , sel , dsel , fns ) ; } } } // convert node to a string var h = outerHTML ( dom ) , pfns = [ ] ; // IE adds an unremovable "selected, value" attribute // hard replace while waiting for a better solution h = h . replace ( / <([^>]+)\s(value\=""|selected)\s?([^>]*)> / ig , "<$1 $3>" ) ; // remove attribute prefix h = h . split ( attPfx ) . join ( '' ) ; // slice the html string at "Sig" var parts = h . split ( Sig ) , p ; // for each slice add the return string of for ( var i = 1 ; i < parts . length ; i ++ ) { p = parts [ i ] ; // part is of the form "fn-number:..." as placed there by setsig. pfns [ i ] = fns [ parseInt ( p , 10 ) ] ; parts [ i ] = p . substring ( p . indexOf ( ':' ) + 1 ) ; } return concatenator ( parts , pfns ) ; }
returns a function that, given a context argument, will render the template defined by dom and directive.
returns a function that given a context argument will render the template defined by dom and directive .