ecwyne / meteor-polymer-elements

Add polymer-elements to Meteor project
https://atmospherejs.com/ecwyne/polymer-elements
59 stars 14 forks source link

how to pass args to attributeObject ? #20

Closed ramstein74 closed 9 years ago

ramstein74 commented 9 years ago

in this example {{> paper_checkbox attrs=attributeObject}}

what if i use this inside an each statment ? for each i want to pass a value to attibuteObject like each param {{> paper_checkbox attrs=attributeObject(param)}} /each how do i do it ?

thank you

ecwyne commented 9 years ago

@ramstein74 there would be two different ways to accomplish this. If you can share your project code I can advise a method to use.

1. Use Template Helper

  Template.myTemplate.helpers({
    attributeObject: function (){
      //"this" is the data context of your template
      return {checked: this.checked}
   }
  });

2. Store object in mongo document

  //mongo document
  {
    "name": "My Name",
    "occupation": "My Occupation",
    "attributeObject": {"checked": true}
  }
ramstein74 commented 9 years ago

Ok if that is the way it works.

Just dont understand why you did it like that. It would be easy to debug if we could write in the html all the params to polymer.

Hiding all inside an object repeatedly for every record i may need, seems a waste of space( if inside collection) and harder to debug and code.

ecwyne commented 9 years ago

Update: there will be an additional way of creating this attribute object using subexpressions! See the proposal here and the PR here