Git Product home page Git Product logo

Comments (5)

LaurentGoderre avatar LaurentGoderre commented on August 15, 2024

I could be wrong but isn't that what {{iterate}} is for?

from handlebars-helpers.

thom4parisot avatar thom4parisot commented on August 15, 2024

@LaurentGoderre it might… haven't spotted this one. Actually it's missing from the live collection documentation :-)

I'll give a go and tell you if it's doing the job.

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

I'll get the iterate helper added to the docs, thanks for the heads up! there are other helpers that need to added as well, please let me know if you notice one that isn't documented.

from handlebars-helpers.

akrawchyk avatar akrawchyk commented on August 15, 2024

@oncletom the syntax described in your original post is not working for me in Assemble 0.4.41 with Handlebars-Helpers 0.5.8. Doesn't seem like the item (in this case an Object) is applied to this context within the template. The following only outputs the value of index, and only outputs the data value when I change {{title}} to {{item.title}} (as expected by https://github.com/assemble/handlebars-helpers/blob/bf98ee5d25b914eff3d841f777c2c0ad35075b3b/lib/helpers/helpers-collections.js#L526) in the template.

Doesn't work:

var data: [
  { 'title': 'First title', 'name': 'First name' },
  { 'title': 'Second title', 'name': 'Second name' }
]

{{#eachIndex data}}
  <h2>{{index}}: {{title}}</h2>
  <p>{{name}}</p>
{{/eachIndex}}

Works:

var data: [
  { 'title': 'First title', 'name': 'First name' },
  { 'title': 'Second title', 'name': 'Second name' }
]

{{#eachIndex data}}
  <h2>{{index}}: {{item.title}}</h2>
  <p>{{item.name}}</p>
{{/eachIndex}}

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

closing based on age. the repo has been refactored, PRs are very welcome for any changes/new helpers

from handlebars-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.