handlebars-repeat

Crates.iohandlebars-repeat
lib.rshandlebars-repeat
version0.1.0
sourcesrc
created_at2021-08-10 17:29:25.457109
updated_at2021-08-10 17:29:25.457109
descriptionBlock repetition helper for handlebars
homepagehttps://github.com/npmccallum/handlebars-repeat
repositoryhttps://github.com/npmccallum/handlebars-repeat
max_upload_size
id434389
size10,220
Nathaniel McCallum (npmccallum)

documentation

README

Workflow Status Average time to resolve an issue Percentage of issues still open Maintenance

handlebars-repeat

This crate provides a handlebars helper function which repeats a block a given number of times (the count). For example:

{{#repeat 3}}
hi
{{/repeat}}

Produces:

hi
hi
hi

Local Variables

Within the repeated block, there are three local variables in addition to the standard context:

  1. @index is an integer indicating the index of the current repetition.
  2. @first is a boolean indicating whether this is the first repetation.
  3. @last is a boolean indicating whether this is the last repetation.

For example:

{{#repeat 3}}
Index: {{@index}} (first: {{@first}}; last: {{@last}})
{{/repeat}}

Produces:

Index: 0 (first: true; last: false)
Index: 1 (first: false; last: false)
Index: 2 (first: false; last: true)

Inverse Block

Like the standard each helper function, repeat can specify an inverse block which will be rendered when count == 0. For example:

{{#repeat 0}}
foo
{{else}}
bar
{{/repeat}}

Produces:

bar

License: MIT

Commit count: 2

cargo fmt