mongodb - Creating fields based on what's returned, meteor pub/sub -


probably bad title, don't know how precisely describe this.

  template.body.helpers({     messages: function () {       return messages.find({}, {         sort: {createdat: -1}       });     }   }); 

this code have. on client side, takes

{{#each messages}}   <span class="text"> {{messagetext}} </span> {{/each}} 

each message contains "text" , "username".

how go about, in "return messages" part, modifying returns?

so like

  template.body.helpers({     messages: function () {       messages.find().foreach(function(thismsg){         messagetext = slugify(thismsg.messagetext)       };     }   }); 

get messages, modify fields , return them. perhaps in subscriptions instead? please help.

you can pass message in helper , can modify message , pass template this.

your template code.

{{#each messages}}   <span class="text"> {{slugifymessage text}} </span> {{/each}} 

you helper code.

template.body.helpers({     messages: function () {       return messages.find({}, {         sort: {createdat: -1}       });     }     slugifymessage: function(messagetext){        return slugify(messagetext);     }   }); 

please make sure text passing slugifymessage same name database mentioned have 2 field named username , text, took text can replace doc field want modify.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -