Skip to content Skip to sidebar Skip to footer

How To Avoid Meteor Helpers Run Multiple Times

In my template I have this HTML:

Solution 1:

The card helper is executed several times since card is present in evaluated template code more than once.

A pattern to avoid duplicate calls in scenarios like the one you're facing is to use #with:

{{#with card}}
  <input id="name"   type="text" value="{{name}}">
  <input id="prefix" type="text" value="{{prefix}}">
  <input id="phone"  type="tel"  value="{{phone}}">
{{/with}}

This will call card once and then run the nested code in the context of its result.


Post a Comment for "How To Avoid Meteor Helpers Run Multiple Times"