return variable && variable.attribute equivalent to more complex
if(variable) return variable.attrubite; return false;
This is necessary because if variable was null - which happens all the time between page loading and collection inflation - calling variable.attribute throws an exception: null has no attributes.
So no, there is no way out of this test. You can choose a different fragrance if it bothers you - personally, I leave the actual return for the last line and check the correctness earlier:
if(! variable) return null; return variable.attribute;
What can be avoided is a line that is also repeated in all your helpers:
user = Meteor.users.findOne(Session.get('edit-user'));
In the above case, all attributes belong to the same object. So why not pass this single object?
userForm.js:
Template.userForm.user = function() { return Meteor.users.findOne(Session.get('edit-user')); }
userForm.html:
<template name="userForm"> <span data-id="{{user._id}}"> Name: {{user.name}}, email: {{user.email}} </span> </template>
or even:
<template name="userForm"> {{#with user}} <span data-id="{{_id}}"> Name: {{name}}, email: {{email}} </span> {{/with}} </template>
source share