Uppercase "a"'s inside a Meteor template -


how can uppercase small a's inside meteor template after rendering?

what tried:

meteor's liverange object has visit() method. can access rendered dom nodes of template. each dom text node modify data in visitor.

however! how liverange object template??

in callback rendered() template this template instance. has liverange object in member called _spark_keezuqtoktbuqw3xw or such. looks meteor disliking access member.

how can liverange object of template in way pleases meteor gods?

and before ask why such stupid thing uppercasing "a"'s: it's complicated. execute search-and-replace on dom text nodes in template, because trying apply cross-cutting concern several templates in meteor application.

do have constraints on a's within template?

for example, how you'd uppercase a's within spans in template:

template.complicated.rendered = function() {      this.findall('span').each(function(idx, element) {         $(element).html( $(element).html().replace(/a/g, 'a');     });  }; 

 


 

if want traverse top-level nodes, can that:

template.complicated.rendered = function() {   var node = this.firstnode;    while(true) {      // manipulate node     //     // example, text nodes within in     // , replace a's a's      if(node === template.lastnode) return;     node = node.nextsibling;   } } 

however, need careful method , replace contents of leaf nodes. if change every a there is, may change link urls don't want change. also, changing dom, not text node contents, may anger meteor gods.

 


 

edit: combined how select text nodes jquery? , code upcase a's in text nodes within template:

template.complicated.rendered = function() {   var node = this.firstnode;    while(true) {      _.each(gettextnodesin(node, false), function(textnode) {       textnode.nodevalue = textnode.nodevalue.replace(/a/g, 'a');     });      if(node === template.lastnode) return;     node = node.nextsibling;   } } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -