mustache / mustache.github.com

The {{official}} website
http://mustache.github.io/
Other
2.29k stars 292 forks source link

Add line numbers. #154

Closed compozitor closed 8 months ago

compozitor commented 1 year ago

It would be nice to automatically add line numbers in the loop. You can add the keyword {{*number}} or whatever. For example:

{
  "stooges": [
    { "name": "Moe" },
    { "name": "Larry" },
    { "name": "Curly" }
  ]
}

Template:

{{#stooges}}
<b>{{*number}}{{name}}</b>
{{/stooges}}

Output:

<b>1Moe</b>
<b>2Larry</b>
<b>3Curly</b>
compozitor commented 1 year ago

You can also add the possibility with what number to start numbering {{number = 0}} or {{number = 1}}.

jgonggrijp commented 8 months ago

Closing this because this repository is about the website and not about the Mustache template language. Please take comments about the template language to https://github.com/mustache/spec/discussions.

Regarding this particular topic, you can find previous discussions via https://github.com/mustache/spec/discussions/163, https://github.com/mustache/spec/discussions/153 and https://github.com/mustache/spec/discussions/164.