output a group of option tags 1 through 10

17 Views Asked by At

I have a group of option tags inside a select. Is there a way to generate these tags for x to y using mustache?

The only way I could think of now is to create an array from 1 to 10 in the controller, then use that variable as a section in the template. Is there a template-only solution?

              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
1

There are 1 best solutions below

1
wazz On

Put the select tag outside of the data and the option tag inside. Each loop of the data creates a new option.

<script id="template05" type="x-tmpl-mustache">
    Results :<br />
    <select>
        {{#data}}
        <option value="{{name}}">{{name}}</option>
        {{/data}}
    </select>
</script>