Was this page helpful?

Indexing Operators

    Table of contents
    1. 1. [] Operator
      1. 1.1. Usage Restrictions
      2. 1.2. Samples

    [] Operator

    Retrieves the value at a specified index (applies to: str, list, map) or xpath (applies to: xml).

    Usage Restrictions

    1.8.1 or later.

    Samples

        Output

    To retrieve the second character in a string:

    {{ "Hello World!"[1] }}

    e

    To retrieve the first value in a list:

    {{ [ 1, 2, 3 ][0] }}

    1

    To retrieve a map item at a specified index name:

    {{ { first: 1, second: 2, third: 3 }["third"] }}

    3

    To retrieve the username element returned from the API using an xpath:

    {{ web.xml("http://wiki.opengarden.org/@api/deki/users")["user/username"] }}
    

       

    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by