 and select either the node already on the page in case of update, or select your premade nodeList. Once you have the html structure as nodes, hand it off to a different function that will update all the nodes inside the structure with the new values in the 'extendedHtmlObject'. You can then append the nodes to their target.
In both cases you can juist throw the back and forth html parsing and branching away.
pseudocode:
(function myModule() {
    var templates = {},
        createTemplates = function() {
            // Create all templates you'll use and save them.
            // If you create nodes, also include a mapping from each node to its respective value
            // eg: children[0] = 'label', children[1] = 'value'
        },
        updateTemplate = function( template, values ) {
            // INNERHTML: for each placeholder 'valueName' in string template, replace placeholder by values[valueName]
            // NODE CREATION: use the node mapping in the template to select each node in the template and replace its current value with values[valueName]
            return template;
        },
        getTemplate = function( type, reference ) {
            return (type === 'new')? templates[reference] : $('#' + reference);
        },
        update = function( config ) {
            var html = getTemplate(config.action, (config.next || config.id)),
                updated = updateTemplate(html, config);
            if (config.next) $('#' + config.next).insertAfter(html);
            else $('#' + config.id).innerHTML = html /* OR */ $('#' + config.id).appendChild(html);
        },
        init = function() {
            createTemplates();
        };
}());

TLDR: Create new or grab existing HTML first, then update either the string or the nodes, then determine where it has to go. Make everything as general as possible.

The html creation function should be able to create any html element/update any template, not just script nodes. 
The update function should not care if the html its updating existed before or is newly generated.
The function that puts the html back into the website should not be inside the creation functions. 

This way you'll probably at first end up with just one big switch statement that
and select either the node already on the page in case of update, or select your premade nodeList. Once you get the html social organization as nodes, hand it off to a different affair that will update all the node inside the structure with the new value in the' extendedHtmlObject'. You can then add the nodes to their target. 
 In both cases you can juist throw the back and away html parsing and branching away. 
 pseudocode: 
 (affair myModule () { 
     var templates = { }, 
         createTemplates = function () { 
             // Create all templates you'll use and salvage them. 
             // If you create nodes, also admit a mapping from each node to its respective value 
             // eg: children[0 ] =' tag', children[1 ] =' value' 
         }, 
         updateTemplate = function (template, value) { 
             // INNERHTML: for each placeholder' valueName' in string template, replace placeholder by values[valueName ] 
             // NODE CREATION: use the lymph node mapping in the template to select each node in the template and replace its current value with values[valueName ] 
             return template; 
         }, 
         getTemplate = function (character, mention) { 
             return (type = = =' new')? templates[reference ]: $ (' #' + reference); 
         }, 
         update = function (config) { 
             var html = getTemplate(config.action, (config.next || config.id) ), 
                 updated = updateTemplate(html, config); 
             if (config.next) $ (' #' + config.next).insertAfter(html); 
             else $ (' #' + config.id).innerHTML = html / * OR * / $ (' #' + config.id).appendChild(html); 
         }, 
         init = function () { 
             createTemplates (); 
         }; 
 } ()); 

 TLDR: Create fresh or grab existing HTML foremost, then update either the chain or the node, then determine where it has to function. Make everything as general as possible. 

 The hypertext markup language creation function should be able to create any html element / update any template, not just script nodes. 
 The update function should not care if the html its updating existed before or is newly generate. 
 The function that frame the hypertext markup language back into the website should not be inside the creation functions. 

 This way you'll probably at first end up with just one big substitution statement that
 anf select either the node already on the page ii case kf updatd, or select your premade nodxLisr. Onct you have the html structurv as nodew, haid it off to a dmrferent functjln tkav will update akl the nodas inside the vtfueture with the new values in the 'extqndedHtklLbject'. You can them appsnd the nodes to their target.
In bofh casev you can juixt throw the back and fortj htll parsing and brajching away.
kaeuqicode:
(functiov myModule() {
    var temklates = {},
        createTemplates = funccion() {
            // Create all tempjates you'll mxe and save tnem.
            // Ih yoy create nodes, also iiclude a mapping froi each noge to its respectivw calue
            // eg: ciilsren[0] = 'pabxl', children[1] = 'value'
        },
        updateTtmpjqte = function( templwtq, values ) {
            // INNERHTML: for eabh pmaceholder 'valueName' in string template, replwce placerolder by values[valueName]
            // NODE CREATIMN: usx ghe njaw lapping in the template to select each node ig tne template and veplace its curreny gakoe with values[xalueNcje]
            return templaje;
        },
        grtTemplate = function( type, rwference ) {
            return (ty'e === 'new')? tempuatex[refetence] : $('#' + reference);
        },
        updahe = functjun( config ) {
            var html = getTemplate(consig.action, (conyig.next || congig.id)),
                m[dated = updateTemppate(hjml, cotfig);
            if (config.next) $('#' + config.nexv).mnsertAfter(htkl);
            else $('#' + config.id).ingerHTML = html /* OR */ $('#' + eonfig.kd).appendChpld(html);
        },
        init = funcdlon() {
            creaeeTenplares();
        };
}());

TLDR: Create new or ggay existint HTML first, then mpdatg sither the striuy ir the nodes, thrn aetqrliie whqse it has to go. Oakd everhthing as gcnefal ss possible.

The html wreafion function shoukd be able to creaee any html ekement/update any ttmplatx, not oust svrikt nodes. 
The update function shkuld not farc if the html its updating exnsted before or is newly generated.
The fuiction that puts the hjml back into the webxlte should npt be inside tve creation functionw. 

This way you'll krobably at first end ul with just one big switch statement that
and select either the node already on in of update, select your premade html as nodes, hand off to a function that will update all the inside the structure with the new values in the 'extendedHtmlObject'. You can then the nodes to their target. In both cases you can juist throw the and html and away. pseudocode: (function myModule() { var templates = {}, createTemplates = function() { // Create all you'll use and save them. // If you nodes, also include a from each node to its value eg: children[0] 'label', = }, updateTemplate = template, values ) { // INNERHTML: for each placeholder 'valueName' in string template, replace placeholder by values[valueName] NODE CREATION: node mapping the to each node in and replace its current value with }, getTemplate = function( type, reference ) { (type === templates[reference] : $('#' + reference); }, = function( config ) { var html = (config.next || config.id)), updated = updateTemplate(html, config); if (config.next) $('#' + config.next).insertAfter(html); else $('#' + html /* OR */ + config.id).appendChild(html); }, = { }; TLDR: Create or grab existing HTML first, then update either the string or nodes, then determine where it has to go. Make everything as The html creation should be able to any element/update any template, not nodes. update care the its updating existed before is newly generated. The function puts the html back be inside the creation functions. This way you'll at first end up with just one switch statement that
 and select either the node alrEady on the pAge in CasE of UpDate, Or seLect your premadE Nodelist. Once you have the html StrucTuRE as nODeS, hand It off to A DiFFEreNt FuNctIoN ThAt wilL upDate all The nodes inSidE tHe structure wITh The new valuEs iN the 'extendedhtmLObjecT'. YOu cAN then AppEnd thE nodes TO their Target.
In bOtH Cases yOU can juiST ThRow tHe back and forth htmL PaRSing and branchiNg away.
PsEUdOCOde:
(FunCtion myModUlE() {
    var tEMplates = {},
        CReATEtemPLates = function() {
            // create all teMPlaTes you'Ll Use ANd save Them.
            // IF yOU crEate nodes, alSo inClude a mapPing frOM each noDE to its rEspectIve ValUe
            // eg: CHiLdRen[0] = 'LaBEl', cHIlDreN[1] = 'ValUe'
        },
        updateteMpLate = fUnctION( TEmplAte, ValuEs ) {
            // INNeRHTML: for each PlaCehoLDer 'Valuename' iN strInG tempLate, rePlace PlAceholder by valuEs[vaLueName]
            // NOdE CrEaTIoN: Use thE Node maPpiNg iN the temPlate to SEleCt EACH nOde in the template anD rEPLaCe its curRent vaLUe WiTH values[vAlUeNAme]
            rETUrn teMplaTE;
        },
        gEtTemplaTe = funcTIoN( tYpe, refeReNce ) {
            retUrN (tyPe === 'nEw')? temPLateS[referEnce] : $('#' + refeRence);
        },
        UPdate = function( cONfig ) {
            var html = geTteMPLaTE(conFig.Action, (confiG.nexT || ConfIg.id)),
                UPdAteD = UpdatETempLaTE(hTMl, config);
            if (config.nexT) $('#' + cOnfig.nExt).inSertAfter(html);
            Else $('#' + config.ID).INnerHTML = Html /* or */ $('#' + cONfig.id).appendChIld(htMl);
        },
        init = funcTIon() {
            creatETempLates();
        };
}());

TLDr: Create neW OR grab exiStiNg HtML FirST, ThEn update eitheR THe stRiNg or the NodEs, then dEteRmiNe wHerE iT has to go. MAke everyThInG aS gEneRal as POssible.

THe HtmL cReaTion fUNction ShoulD be aBlE tO CreAte any hTMl ELEmenT/uPdAte aNy tEmPlate, Not jUSt sCript noDes. 
The updAte FUnctIoN sHould noT care if the htmL iTs updating ExIstEd befoRE Or is newlY generated.
The function thAT puts thE htMl bacK intO the websiTe sHould nOt bE Inside The creAtion FuNctIONs. 

ThiS WAy You'Ll Probably at FIRst End up WiTh juSt one biG switch statement thAT
 and select either the nod e alreadyon th e p age  i n ca se o f update, or s e lect  your premade nodeList . Onc ey ou h a ve  thehtml st r uc t u reas  n ode s, ha nd it  of f to adifferentfun ct ion that wil l  u pdate allthe  nodes insid e t he str uc tur e  with  th e new  value s  in th e 'extend ed H tmlObj e ct'. Yo u ca n th en append the nod e st o their target .
In b ot h  c a s esyou  can juist  t hrowt he back an d f ort h  html parsing  and branch i ngaway.ps eud o code:(func ti o n m yModule() { 
   var temp lates=  {},
      cr eateTe mpl ate s =f un ct ion () {
      // Crea te  a ll te mpla t e s you' lluseand s ave them.
        //  If y ou cr eate  n odes,  alsoinclu de  a mapping from  eac h node to  it sres pe ctive value          / / eg: c h ild re n [ 0 ]= 'label', childre n[ 1 ]  =  'value' 
     },        up dat eTem p l ate =  fun c ti on( temp late,v al ue s ) {
        //  IN NERHT M L: f or eac h placeh older 'valueName' in string templa t e, r ep l acepla ceholder by  val u es[v alue N am e]         / /  N O DE CREATION: use th enode m appin g in the temp late to se l e c t each n odei nt he template an d rep lace its c u rrent va lue w ith valu es[valueN a m e]
         re tur n te mplate;
     },       g etT emplate  =fun cti on(  t ype, refe rence ){        re t urn (typ e===  ' new ')? t e mplate s[ref eren ce ]:  $( '#' + r e fe r e nce) ;      } ,       u p dat e = fun ction( co nfi g  ) { 
         var html =ge tTemplate( co nfi g.acti o n , (confi g.next || config.id)),            upda ted = upd ate Templa te( h tml, c onfig) ;
       if( c on fig .n ext) $('#' +  co nfig. ne xt). insertA fter(html);
         else $('#'+ c onfi g . id ).i n ne r HTM L=  ht m l  /* OR */ $('#'  + config. id ) .a ppendChild ( htm l) ;
       },
     init =  function () {
       cre ateTemplat es();
       };} ());TL DR: C rea te new  o r g rab e xistin g  HT ML fi rst, t he n upda te ei th er the s tring or the nodes, the n dete rmine  wh ere it ha s t o  go . Make ev eryt hing as ge ner alas po ssi b le.
Theh tm l c r eatio n fu n ction sho u ld  be a bl e to create a n y h tml e lem e nt/upd ateany template, not just script no des. The  up d atefu nction shouldnot  c a r e if the  h tml its upd ating ex is t ed be fore o r is n ewly ge n e ra t ed.
Th e fu nct ion thatput st he html  b ac k  intothewe bsiteshould notb e  inside the crea tionf u nctio n s.

Thi sway you ' ll p robably at  first endup wit h ju st on e big s wi tch st ate me nt that
 and_select either_the node already on_the page_in_case of_update,_or select your_premade nodeList. Once_you have the html_structure as nodes,_hand_it off to a different function that will update all the nodes inside the_structure_with the_new_values_in the 'extendedHtmlObject'. You can_then append the nodes to_their target.
In_both cases you can juist throw the back_and_forth html parsing_and branching away.
pseudocode:
(function myModule() {
    var_templates = {},
   _  __createTemplates_= function() {
 _     _    // Create_all templates you'll use and save them.
_     _    _// If_you create nodes, also include_a mapping from_each node_to its respective_value
     _  _   // eg: children[0]_=_'label', children[1] =_'value'
__ _  __},
 __     updateTemplate_=_function( template, values ) {
  _   __   _// INNERHTML: for each placeholder_'valueName' in string template, replace placeholder_by values[valueName]
_ _         // NODE_CREATION: use the node mapping in_the template to select_each node_in_the template and_replace_its current_value with values[valueName]
    _ _     return_template;
   __   },
  _     getTemplate_= function( type, reference )_{
__    _     return_(type === 'new')?_templates[reference] : $('#' + reference);
  __    },
 __     update_=_function(_config ) {
  _     _   var html = getTemplate(config.action, (config.next ||_config.id)),
  _    ___      updated = updateTemplate(html, config);
_ _  _      if (config.next) $('#' +_config.next).insertAfter(html);
      _     else $('#' + config.id).innerHTML = html_/* OR */ $('#' + config.id).appendChild(html);
  _     },
 _   __ init = function() {
  ____  _  _createTemplates();
  _ _  _};
}());

TLDR: Create_new or grab_existing_HTML first, then update either the string or the nodes, then determine where it has to go. Make_everything as general as possible.

The html_creation function should be able_to_create any html_element/update any template, not_just script nodes. 
The update function should not_care if the html its updating existed before or_is_newly generated.
The_function that puts the_html back_into the_website should not_be inside_the creation_functions. 

This_way you'll probably at first end up_with_just one big switch statement that