Comments (13)
It is available: {{=$itemNumber}}. You'll see it used in several samples, such as https://github.com/BorisMoore/jsrender/blob/master/demos/step-by-step/01_inserting-data.html
http://borismoore.github.com/jsrender/demos/step-by-step/01_inserting-data.html
[But see below for update. Syntax has changed...]
from jsrender.
hi boris,
thank you for your attention. i had a close look at your examples (just to
avoid my current position).
i haven't noticed the $, that's how i thought that itemNumber, Name, and
ReleaseYear all came from data:
{{=$itemNumber}}: {{=Name}} ({{=ReleaseYear}})
maybe {{=$ctx.index}} might be clearer, but the functionality is there, the
rest is personal taste.
thank you very much.
burk
On Wed, Dec 7, 2011 at 12:24 AM, Boris Moore <
[email protected]
wrote:
It is available: {{=$itemNumber}}. You'll see it used in several samples,
such as
https://github.com/BorisMoore/jsrender/blob/master/demos/step-by-step/01_inserting-data.htmlhttp://borismoore.github.com/jsrender/demos/step-by-step/01_inserting-data.html
Reply to this email directly or view it on GitHub:
#33 (comment)
from jsrender.
Hi Boris
<li><a href="#">{{=page}}</a></li>
{{#each arrPages}}
<li<a href="#">{{=page}}: {{=$itemNumber}}</a></li>
{{/each}}
I can't access the {{=page}} within the each loop. Is this possible?
thanks, Joe.
from jsrender.
#34 says it all...
from jsrender.
brilliant, thanks
from jsrender.
Is there a way to print a zero-based index?
I'm looking for something like
{{#each}}
<div id="myBlock_{{=$zeroIndex}}">
{{/each}}
from jsrender.
For now, you have to call a helper function to do $itemNumber-1
, but in Beta bits (coming soon I hope) it will be zero-based, and you will also be able to increment or decrement inline. In fact you will be able to write {{:#index}}
for zero-based and {{:#index+1}}
for 1-based. But more on that when the update is available... [See below for update]
from jsrender.
Thanks! much appreciated.
Christian Hain
On Feb 22, 2012, at 8:37 PM, Boris Moore wrote:
For now, you have to call a helper function to do
$itemNumber-1
, but in Beta bits (coming soon I hope) it will be zero-based, and you will also be able to increment or decrement inline. In fact you will be able to write{{:#index}}
for zero-based and{{:#index+1}}
for 1-based. But more on that when the update is available...
Reply to this email directly or view it on GitHub:
#33 (comment)
from jsrender.
Some changes have been made the design.
#key corresponds to what was #index, and #index is now the inherited integer index from what the nearest parent view that has an integer index.
So #index is now unchanged when you wrap {{:#index}} in an {{if}} block.
from jsrender.
Further update: To access a zero-based index from an 'item' view, use {{:#index}}
. To access the index from nested contexts such as {{if}}
blocks, use {{:#getIndex()}}
from jsrender.
hey @BorisMoore have a range o for but decreasing...
for example
"{^{range members ^start=10 ^end=1}}"+
"{^{:#index}}"+
"{{/range}}"+
from jsrender.
@trifolius: Hi. What is your question?
from jsrender.
@trifolius: You should be able to create a custom tag to do that. You can use a combination of the approach used for the {{sort}} example, here: http://www.jsviews.com/#samples/jsr/tags/wrap-content and here: http://www.jsviews.com/#samples/jsr/helpers
and the {{range}} tag shown here: http://www.jsviews.com/#samples/jsr/tags/extend-for and here: http://www.jsviews.com/#samples/tag-controls/range
from jsrender.
Related Issues (20)
- template content in external files HOT 2
- renderFile to accept a file as input HOT 2
- Nested props loop is not picking up properties of a function HOT 4
- any breaking changes between 0.9.82 and current 1.0.5 ? HOT 2
- JSRender strips multiple white spaces from input HOT 3
- Node + jsRender: allow absolute paths, (and also passing context to renderFile) HOT 8
- space is not html-encoded HOT 6
- regex not working HOT 2
- Difference between Browser and Node app - Null Propagation Operator HOT 2
- Conditional check if equal to string HOT 5
- Incomplete jsrender.min.map file HOT 2
- Provide support for passing an ID selector to $.templates() even when using JsRender without jQuery HOT 6
- Please provide a good documentation on how to use this in Angular 8+ or React 9+ versions HOT 2
- {{if}} tag doesn't work on keys with array or object with properties HOT 1
- swig.renderFile gives callback function required error HOT 3
- Chrome Extension Manifest V3 HOT 3
- $(...).render is not a function HOT 1
- How can I load data from jsrender template and update it HOT 2
- Using a tmpl selector that begins with a # but is not an ID selector does not work HOT 1
- Get an error t is not a function when adding if block HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsrender.