Skip to content
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 would I render a nested array #43

Closed
ultraflynn opened this issue Jan 12, 2012 · 6 comments
Closed

How would I render a nested array #43

ultraflynn opened this issue Jan 12, 2012 · 6 comments

Comments

@ultraflynn
Copy link

Consider the following JSON:

{ "locations" : [ "All",
      "Europe",
      "Asia",
      "America",
      "India"
    ]}

I'm using this JS:

Tempo.prepare("locations").render(data.locations);

I need to render this JSON on a page. What should I use as a placeholder for the name of the location?

e.g.

<ul id="locations" class="menu">
    <li data-template>
        {{?????}}
    </li>
</ul>
@tmenier
Copy link

tmenier commented Apr 12, 2012

Did you ever figure this out? This is driving me nuts. It comes down to how to render the object when it's a string or other simple type, where you want to render the object itself and not a property of it, so none of the examples in the docs seem to apply.

I've seen other templating engines that support something like {{this}}, but I don't know if Tempo has an equivalent.

@mrolafsson
Copy link
Contributor

I'm so sorry for not replying guys - I do not understand this, I've set Github to notify me of new issues but for some reason I never get these. You're right, you've spotted a gap in this. I will look into a solution now and update ASAP.

@oriolj
Copy link

oriolj commented Apr 18, 2012

+1, thanks for the great work!

@mrolafsson
Copy link
Contributor

Hey guys, thanks for your patience! I've just patched 1.8 to support referring to the object being iterated (whether an array element or not). You can use {{.}} to get a reference to it. See example: http://jsfiddle.net/wcNm4/

@tmenier
Copy link

tmenier commented Apr 18, 2012

Cool, thanks for the quick turn-around!! FYI, I posted the question on SO the same day, if you want to paste your answer there I'll gladly accept it:

http://stackoverflow.com/questions/10132718/tempo-js-rendering-an-array-of-strings-or-simple-objects-referring-to-this

(Was gonna answer it myself but you deserve the rep points if you want them)

@mrolafsson
Copy link
Contributor

Thanks very much Todd!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants