hsp/rt/cptcomponent.js
function () {
    this.attEltNodes=null;
    this._attGenerators=null;

    // determine the possible template attribute names
    var tpAttNames={}, ca=this.ctlAttributes, defaultTplAtt=null, lastTplAtt=null, count=0;
    for (var k in ca) {
      if (ca.hasOwnProperty(k) && ca[k].type==="template") {
        // k is defined in the controller attributes collection
        // so k is a valid template attribute name
        tpAttNames[k]=true;
        count++;
        if (ca[k].defaultContent) {
          defaultTplAtt=k;
        }
        lastTplAtt=k;
      }
    }

    // if there is only one template attribute it will be automatically considered as default
    if (!defaultTplAtt) {
      if (count===1) {
        defaultTplAtt=lastTplAtt;
      } else if (count>1) {
        // error: a default must be defined
        log.error(this+" A default content element must be defined when multiple content elements are supported");
        // use last as default
        defaultTplAtt=lastTplAtt;
      }
    }

    // check if a default attribute element has to be created and create it if necessary
    this.manageDefaultAttElt(defaultTplAtt);

    // Analyze node attributes to see if a template attribute is passed as text attribute
    var atts=this.atts, att, nm;
    if (atts) {
      for (var k in atts) {
        if (!atts.hasOwnProperty(k)) continue;
        att=atts[k];
        nm=att.name;
        if (tpAttNames[nm]) {
          // nm is a template attribute passed as text attribute
          if (this.tplAttributes && this.tplAttributes[nm]) {
            // already defined: raise an error

            log.error(this+" Component attribute '" + nm + "' is defined multiple times - please check");
          } else {
            // create new tpl Attribute Text Node and add it to the tplAttributes collection
            if (!att.generator) {
              var txtNode;
              if (att.value) {
                // static value
                txtNode = new $TextNode(0,[""+att.value]);
              } else {
                // dynamic value using expressions
                txtNode = new $TextNode(this.exps,atts[k].textcfg);
              }
              if (!this._attGenerators) {
                this._attGenerators = [];
              }
              att.generator = new $CptAttElement(nm,0,0,0,[txtNode]); // name, exps, attcfg, ehcfg, children
              this._attGenerators.push(att.generator);
            }
            // generate a real $CptAttElement using the TextNode as child element
            var ni=att.generator.createNodeInstance(this);
            ni.isCptContent=true;
            if (!this.attEltNodes) {
              this.attEltNodes=[];
            }
            this.attEltNodes.push(ni);
            // attribute elements will automatically register through registerAttElement()
          }
        }
      }
    }

    this.retrieveAttElements();
  }
function () {
    this.attEltNodes=null;
    this._attGenerators=null;

    // determine the possible template attribute names
    var tpAttNames={}, ca=this.ctlAttributes, defaultTplAtt=null, lastTplAtt=null, count=0;
    for (var k in ca) {
      if (ca.hasOwnProperty(k) && ca[k].type==="template") {
        // k is defined in the controller attributes collection
        // so k is a valid template attribute name
        tpAttNames[k]=true;
        count++;
        if (ca[k].defaultContent) {
          defaultTplAtt=k;
        }
        lastTplAtt=k;
      }
    }

    // if there is only one template attribute it will be automatically considered as default
    if (!defaultTplAtt) {
      if (count===1) {
        defaultTplAtt=lastTplAtt;
      } else if (count>1) {
        // error: a default must be defined
        log.error(this+" A default content element must be defined when multiple content elements are supported");
        // use last as default
        defaultTplAtt=lastTplAtt;
      }
    }

    // check if a default attribute element has to be created and create it if necessary
    this.manageDefaultAttElt(defaultTplAtt);

    // Analyze node attributes to see if a template attribute is passed as text attribute
    var atts=this.atts, att, nm;
    if (atts) {
      for (var k in atts) {
        if (!atts.hasOwnProperty(k)) continue;
        att=atts[k];
        nm=att.name;
        if (tpAttNames[nm]) {
          // nm is a template attribute passed as text attribute
          if (this.tplAttributes && this.tplAttributes[nm]) {
            // already defined: raise an error

            log.error(this+" Component attribute '" + nm + "' is defined multiple times - please check");
          } else {
            // create new tpl Attribute Text Node and add it to the tplAttributes collection
            if (!att.generator) {
              var txtNode;
              if (att.value) {
                // static value
                txtNode = new $TextNode(0,[""+att.value]);
              } else {
                // dynamic value using expressions
                txtNode = new $TextNode(this.exps,atts[k].textcfg);
              }
              if (!this._attGenerators) {
                this._attGenerators = [];
              }
              att.generator = new $CptAttElement(nm,0,0,0,[txtNode]); // name, exps, attcfg, ehcfg, children
              this._attGenerators.push(att.generator);
            }
            // generate a real $CptAttElement using the TextNode as child element
            var ni=att.generator.createNodeInstance(this);
            ni.isCptContent=true;
            if (!this.attEltNodes) {
              this.attEltNodes=[];
            }
            this.attEltNodes.push(ni);
            // attribute elements will automatically register through registerAttElement()
          }
        }
      }
    }

    this.retrieveAttElements();
  }
function ( ) { this . attEltNodes = null ; this . _attGenerators = null ; // determine the possible template attribute names var tpAttNames = { } , ca = this . ctlAttributes , defaultTplAtt = null , lastTplAtt = null , count = 0 ; for ( var k in ca ) { if ( ca . hasOwnProperty ( k ) && ca [ k ] . type === "template" ) { // k is defined in the controller attributes collection // so k is a valid template attribute name tpAttNames [ k ] = true ; count ++ ; if ( ca [ k ] . defaultContent ) { defaultTplAtt = k ; } lastTplAtt = k ; } } // if there is only one template attribute it will be automatically considered as default if ( ! defaultTplAtt ) { if ( count === 1 ) { defaultTplAtt = lastTplAtt ; } else if ( count > 1 ) { // error: a default must be defined log . error ( this + " A default content element must be defined when multiple content elements are supported" ) ; // use last as default defaultTplAtt = lastTplAtt ; } } // check if a default attribute element has to be created and create it if necessary this . manageDefaultAttElt ( defaultTplAtt ) ; // Analyze node attributes to see if a template attribute is passed as text attribute var atts = this . atts , att , nm ; if ( atts ) { for ( var k in atts ) { if ( ! atts . hasOwnProperty ( k ) ) continue ; att = atts [ k ] ; nm = att . name ; if ( tpAttNames [ nm ] ) { // nm is a template attribute passed as text attribute if ( this . tplAttributes && this . tplAttributes [ nm ] ) { // already defined: raise an error log . error ( this + " Component attribute '" + nm + "' is defined multiple times - please check" ) ; } else { // create new tpl Attribute Text Node and add it to the tplAttributes collection if ( ! att . generator ) { var txtNode ; if ( att . value ) { // static value txtNode = new $TextNode ( 0 , [ "" + att . value ] ) ; } else { // dynamic value using expressions txtNode = new $TextNode ( this . exps , atts [ k ] . textcfg ) ; } if ( ! this . _attGenerators ) { this . _attGenerators = [ ] ; } att . generator = new $CptAttElement ( nm , 0 , 0 , 0 , [ txtNode ] ) ; // name, exps, attcfg, ehcfg, children this . _attGenerators . push ( att . generator ) ; } // generate a real $CptAttElement using the TextNode as child element var ni = att . generator . createNodeInstance ( this ) ; ni . isCptContent = true ; if ( ! this . attEltNodes ) { this . attEltNodes = [ ] ; } this . attEltNodes . push ( ni ) ; // attribute elements will automatically register through registerAttElement() } } } } this . retrieveAttElements ( ) ; }
Load the component sub-nodes that correspond to template attributes
Load the component sub - nodes that correspond to template attributes