New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access $value with new syntax #25

Closed
pamelafox opened this Issue Nov 17, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@pamelafox

pamelafox commented Nov 17, 2011

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!

    @BorisMoore

    This comment has been minimized.

    Show comment
    Hide comment
    @BorisMoore

    BorisMoore Nov 18, 2011

    Owner

    $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 ....

    Owner

    BorisMoore commented Nov 18, 2011

    $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 ....

    @pamelafox

    This comment has been minimized.

    Show comment
    Hide comment
    @pamelafox

    pamelafox Nov 19, 2011

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

    pamelafox commented Nov 19, 2011

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

    @BorisMoore

    This comment has been minimized.

    Show comment
    Hide comment
    @BorisMoore

    BorisMoore Nov 19, 2011

    Owner

    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...

    Owner

    BorisMoore commented Nov 19, 2011

    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

    @BorisMoore

    This comment has been minimized.

    Show comment
    Hide comment
    @BorisMoore

    BorisMoore Jun 26, 2012

    Owner

    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 http://www.borismoore.com/2012/03/approaching-beta-whats-changing-in_06.html for details.

    Owner

    BorisMoore commented Jun 26, 2012

    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 http://www.borismoore.com/2012/03/approaching-beta-whats-changing-in_06.html for details.

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