Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26206 > unrolled thread
| Started by | JRough <janis.rough@gmail.com> |
|---|---|
| First post | 2014-11-25 10:10 -0800 |
| Last post | 2014-11-25 23:09 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.javascript
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
| From | JRough <janis.rough@gmail.com> |
|---|---|
| Date | 2014-11-25 10:10 -0800 |
| Subject | how to change a mustache script |
| Message-ID | <3d07171d-ca6d-42f1-b682-f951019b361c@googlegroups.com> |
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,
[toc] | [next] | [standalone]
| From | Chris Riesbeck <Chris.Riesbeck@gmail.com> |
|---|---|
| Date | 2014-11-25 12:35 -0600 |
| Message-ID | <cdk0ffFc8nsU1@mid.individual.net> |
| In reply to | #26206 |
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.
[toc] | [prev] | [next] | [standalone]
| From | JRough <janis.rough@gmail.com> |
|---|---|
| Date | 2014-11-25 11:03 -0800 |
| Message-ID | <494368d6-ed24-4c75-9b9e-8e469a3f875c@googlegroups.com> |
| In reply to | #26207 |
On Tuesday, November 25, 2014 10:35:33 AM UTC-8, Chris Riesbeck wrote:
> 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.
I can't change the data model because I need the tab on the page otherwise I don't have a page but on that page I don't want the list. Isn't there a helper function?
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-11-25 23:09 +0100 |
| Message-ID | <10350011.hofcM1bAHL@PointedEars.de> |
| In reply to | #26206 |
JRough wrote:
> I need to change the mustache code.
How did you get the idea that this would be on-topic here?
> [Google Groups-created code soup]
Please read the FAQ.
> <li class="{{#if isCurrent && !== "activity-tab"}}current{{/if}}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If your posting is remotely on-topic here, that line contains a syntax
error.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web