Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26207
| From | Chris Riesbeck <Chris.Riesbeck@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: how to change a mustache script |
| Date | 2014-11-25 12:35 -0600 |
| Message-ID | <cdk0ffFc8nsU1@mid.individual.net> (permalink) |
| References | <3d07171d-ca6d-42f1-b682-f951019b361c@googlegroups.com> |
On 11/25/2014 12:10 PM, JRough wrote:
> I need to change the mustache code. Basically if a web page is on a certain tab then it adds the class="current" to the <li>. I need it to skip one tab call activity-tab. How would I do this?
> <ul>
> {{# each tab}}
> <li class="{{#if isCurrent}}current{{/if}}" id="{{id}}" test-event="{{id}}" tabindex="1">
> <h4 >{{name}}</h4>
> </li>
> {{/each}}
>
> ---------------------------Something like---------------
>
> {{# each tab}}
> <li class="{{#if isCurrent && !== "activity-tab"}}current{{/if}}" id="{{id}}" test-event="{{id}}" tabindex="1">
> <h4 >{{name}}</h4>
> </li>
> {{/each}}
>
> thanks,
>
Mustache tries to be as logic-less as possible, to keep the HTML
uncluttered. The logic should be in the JavaScript that creates the data
you feed to Mustache. Change your JavaScript to create a data model that
has the desired class for each tab in it, then in the template, just
iterate over the tabs and insert the class.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to change a mustache script JRough <janis.rough@gmail.com> - 2014-11-25 10:10 -0800
Re: how to change a mustache script Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2014-11-25 12:35 -0600
Re: how to change a mustache script JRough <janis.rough@gmail.com> - 2014-11-25 11:03 -0800
Re: how to change a mustache script Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-25 23:09 +0100
csiph-web