Giter Club home page Giter Club logo

Comments (12)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Done in JS and PHP too

Original comment by [email protected] on 7 Nov 2009 at 9:16

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024

Original comment by [email protected] on 7 Nov 2009 at 9:16

  • Added labels: Todo-Java

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024

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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
@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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Update worked right out of the box, thanks!!

Original comment by [email protected] on 10 Nov 2009 at 3:01

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.