tldr
tldr

Reputation: 12112

How do I display a list of elements in the Play! Framework?

I have a list of elements that I pass as an argument into the render method. I have no experience in HTML though and was wondering how I'd print all elements in the list?

Upvotes: 0

Views: 1286

Answers (2)

emt14
emt14

Reputation: 4896

if using play 1.2.x with Groovy templates:

<ul>
  #{list items:myList, as:'element'}
    <li>${element.name}</li>
  #{/list}
</ul>

Upvotes: 1

aaberg
aaberg

Reputation: 2273

I assume that you are using playframework 1.x

if you call render(myElements) from your controller, an myElements is a list of strings, it will look something like this in your view.

...
<ul>
  #{list myElements, as:'elem'}
    <li>&{elem}</li>
  #{/list}
</ul>
...

I will advice you to read the documentation on playframework.org. It is really good and easy to read. You will probably learn a lot. If you want to learn html, I think w3schools.com is a good starting point.

Upvotes: 2

Related Questions