Iteration over object in backbone coffee-haml template?

Asked By: Anonymous

I am trying to iterate over a backbone collection object and print one of it’s attributes into a unlinked list on a haml-coffee template (.hamlc).

In context, I have a collection of fonts. I want to print the name of each font onto the template.

This is how imagine the code is going to look:

  - for font in @fonts

However, this does not iterate at all. I can put any input in this for loop and it simply doesn’t execute.

This is what @fonts looks like when output to the console.log

Object {0: Object, 1: Object, 2: Object, 3: Object, 4: Object…}
0: Object
_id: "50bed321dbc554c7a0000005"
data: Object
name: "Actor"
user_ids: Array[0]
__proto__: Object
1: Object
2: Object
3: Object

How do I iterate over this object and output and print each name in the template?


Answered By: Anonymous

It seems you should specify which attribute of @fonts collection you are about to display like this :

 - for font in
     = font

If you’d like to iterate over object or collection you use :

- for name, location of @fonts
  = name + "lives in" + location

(for example, in case your fonts object has name and location properties)

In your code just replace ‘in’ with ‘of’ .

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen Windows 10 Lisans Office 2019 Mac Satın Al follower kaufen instagram follower kaufen porno