Comments (12)
Done in the Python version:
http://code.google.com/p/json-template/source/detail?r=286
Original comment by [email protected]
on 26 Sep 2009 at 8:48
- Changed state: Started
from json-template.
Done in JS and PHP too
Original comment by [email protected]
on 7 Nov 2009 at 9:16
from json-template.
Original comment by [email protected]
on 7 Nov 2009 at 9:16
- Added labels: Todo-Java
from json-template.
Original comment by [email protected]
on 9 Nov 2009 at 6:58
- Changed title: Provide @Index variable for the current array index
from json-template.
Assume:
{
"url-base": "http://example.com/music/",
"playlist-name": "Epic Playlist",
"songs": [
{
"url": "1.mp3",
"artist": "Grayceon",
"bandmembers": [
{
"name": "Joe Singer",
"intrument": "vocals"
},
{
"name": "Joe Drummer",
"intrument": "drums"
}
],
"title": "Sounds Like Thunder"
},
{
"url": "2.mp3",
"artist": "Thou",
"bandmembers": [
{
"name": "Joe Singer",
"intrument": "vocals"
},
{
"name": "Joe Drummer",
"intrument": "drums"
}
],
"title": "Their Hooves Carve Craters in the Earth"
}
]
}
and
var t = jsontemplate.Template("
{.section songs}\n
<h2>Songs in '{playlist-name}'</h2>\n\n
<table width=\"100%\">\n
{.repeated section @}\n
<tr>\n
<td><a href=\"{url-base|htmltag}{url|htmltag}\">Play</a>\n
<td><i>{title}</i></td>\n
{.section bandMembers\n
<td>{artist}<br />\n
<table width=\"100%\">\n
{.repeated section @}\n
<tr>\n
<td>{$index}</td>\n
<td><i>{intrument}</i></td>\n
<td>{name}</td>\n
</tr>\n
{.end}\n
</table>\n
</td>\n
{.end}\n
</tr>\n
{.end}\n
</table>\n
{.or}\n
<p><em>(No page content matches)</em></p>\n
{.end}\n");
Will $index return (1, 2) or (5, 6, 10, 11)? I mean is it an index for the
current
array or is it a gloabl index like $pos?
Is ther a $pos? I downloaded the latest for JavaScript and tested, got nothing
but
undefined errors.
Original comment by [email protected]
on 9 Nov 2009 at 9:47
from json-template.
@index should return the topmost/innermost index thing. Each repeated section
starts
@index counting from 1.
I'm not sure where the 5/6 10,11 come from in your example. The behavior is
verified
in this test case.
http://chubot.org/json-template/test-cases/testTwoIndices-01.html
There is no @pos. If you mean @index then it might not be released yet. I'll
do a
release now since the code is stable.
Original comment by [email protected]
on 10 Nov 2009 at 2:41
from json-template.
Yeah, that doesn't work. Error: exception thrown and not caught, debuger drops
me at
throw {
name: 'UndefinedVariable', message: name + ' is not defined'
}
Original comment by [email protected]
on 10 Nov 2009 at 2:54
from json-template.
I just a released a new one a few minutes ago. It should work as its verified
by
tests. Note it's @index, not $index. This is parallel with @ for the cursor.
Original comment by [email protected]
on 10 Nov 2009 at 2:55
from json-template.
Update worked right out of the box, thanks!!
Original comment by [email protected]
on 10 Nov 2009 at 3:01
from json-template.
Hey, I just released an update of json-template.js with incompatible API
changes.
I doubt that you have used the APIs since they were not documented very well,
but I
would recommend updating.
Sorry if this caused any inconvenience, but I wanted to rename the methods to
comply
with common JavaScript style. I released 4 days ago without realizing that I
hadn't
done this yet.
It will affect you if you wrote formatters/predicates that accept a context
context.Lookup() --> context.get()
Or if you wrote any custom FunctionRegistry objects:
registry.Lookup --> registry.lookup()
Documented here: http://code.google.com/p/json-template/wiki/RecommendedApi
And committed here:
http://code.google.com/p/json-template/source/detail?r=e6b1d56a7796816d492dfcd9e
4c845b844510f4b
Original comment by [email protected]
on 14 Nov 2009 at 8:40
from json-template.
How can i use @index to indicate odd and even columns in a table?
Original comment by [email protected]
on 5 Jul 2015 at 11:32
from json-template.
Using @index with table ROWS is more conventional.
COLUMNS probably require <colgroup> and <col> tags. If the number of columns
is static (doesn't depend on template data), then you shouldn't need JSON
Template variables at all.
Most tables I've created have static columns.
Here is an example of @index,
http://chubot.org/json-template/test-cases/testIndex-01.html
You can add a formatter like this:
{@index|even-odd}
even-odd could be registered as a function that returns "blue" or "red"
depending on the value of @index.
There should be some examples of how to register formatters in the unit tests.
Original comment by [email protected]
on 5 Jul 2015 at 6:55
from json-template.
Related Issues (20)
- Unbalanced section push and pop in the Java implementation HOT 3
- Add a LISP-style "let" statement
- A predicate containing the text 'or' results in a template parsing error
- typo in UrlParamsJsonTemplateFormatter HOT 2
- Error in JsonTemplateModule::FromFile() HOT 1
- Iteration over dictionary - Patch for /python/jsontemplate/_jsontemplate.py HOT 1
- Iteration over dictionary - Patch for /python/jsontemplate/_jsontemplate.py HOT 1
- cannot pip install json-template
- Javascript within JSON templates HOT 1
- <img> src being ignored. HOT 1
- Possibly a typo introduced by revision cc10d7e78b94 HOT 1
- HTML formatter doesn't work for numeric values HOT 2
- expand sometime return blank HOT 1
- Patch for /jesyll-doc/__config.json
- token_re_cache in javascript implementation doesn't do anything? HOT 2
- Setup.py dependency chaining broken; fix enclosed HOT 1
- Python 3 diff HOT 1
- json data formte with metdata of object HOT 1
- Iteration over dictionary (patch) HOT 2
- saite de filmes
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 json-template.