How to access $value with new syntax #25

pamelafox opened this Issue Nov 17, 2011 · 4 comments


None yet

2 participants


In jQuery templates, I could use $value to get the value of an item in a list, for example. I can't manage to figure out how to do that with the jsRender templates.

For example, given this list:
['dogs', 'cats', 'monkeys']

and this template:

<script id="log-tags-tmpl" type="text/x-jquery-tmpl">
  • {{=$value }}
  • </script>

    What should go instead of {{=$value }}?

    I've looked through the demos but don't think I saw an example using a flat list. Thanks!


    $data will get you the current data item. So you can do {{#each myArray}}{{=$data}}{{/each}} with the above array.

    (Note: see the UPDATE below for current syntax).

    BTW, a tip - for debugging within the compiled template: Set $.views.allowCode = true; and then add {{*debugger;}} within the template, e.g. {{*debugger;}}<li ....


    Thanks! You can close this issue, or perhaps leave it as a reminder to document that/make a demo of it.


    I'll close, since there are so many things that still need documentation and demos... :).
    But stay tuned and reopen, by all means, if you see that it doesn't come when the documentation begins to be more complete...

    @BorisMoore BorisMoore closed this Nov 19, 2011

    UPDATE: The syntax has changed since the above discussion took place. The {{#each ...}} tag is now {{for }} and {{=...}} is now {{:...}}, or {{>...}} if you want HTML encoded values. $data is `#data'.

    So the example above is now: {{for myArray}}{{>#data}}{{/for}}

    See for details.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment