1

I have this mustache template:

{{#pages}}
  <ul class="nav navbar-nav">
    <li><a href="page/{{slug}}.html">{{title}}</a></li>
  </ul>
{{/pages}}

Now there are more than 50 pages but I want to be able to show only 10 pages. How to do that in mustache eg limiting the iterations to specific number something like:

{{#pages:10}} <-- 10 added here as example
  <ul class="nav navbar-nav">
    <li><a href="page/{{slug}}.html">{{title}}</a></li>
  </ul>
{{/pages}}

I searched the documentation but could not find the solution.

Thanks for the help

Dev01
  • 4,082
  • 5
  • 29
  • 45
  • No logic possible in mustache. You'll have to limit the number of pages before you pass them to the template. – Pevara Apr 02 '15 at 22:28

1 Answers1

3

Handlebars is designed as a logic-less templating system. They don't want you to do this in the template.

That said, you should restructure your data (in js/php/whatever) before it gets to the template. e.g...

var firstPage = pages.slice(0, 10);

posit labs
  • 8,951
  • 4
  • 36
  • 66