0
 [{ Url: 'http://example.com', Shortname: 'shortname', Name: 'nameaaa' }, { Url: 'fsadfsad', Shortname: 'aaa', Name: 'fasfsad' } ]

Thanks.

Aᴍɪʀ
  • 7,623
  • 3
  • 38
  • 52
Imran Khan
  • 29
  • 1
  • 9

2 Answers2

5

You loop in ejs always the same way as you loop in regular javascript. So, for example if

 data = [{ Url: 'http://example.com', Shortname: 'shortname', Name: 'nameaaa' }, { Url: 'fsadfsad', Shortname: 'aaa', Name: 'fasfsad' } ]

You could do something like this to loop through the data array.

<% for (var key in data) { %>
    <h3><%= data[key].Url %></h3>
    <h3><%= data[key].Shortname %></h3>
    <h3><%= data[key].Name %></h3>
<% } %>
hassan
  • 185
  • 1
  • 6
0

its was a issue with my schema defining.

"navigation": {
            "type": "List",
            "title": "Navigation",
            "itemType": "Object",
            "subSchema": {
                "Name": {
                    "type": "Text",
                    "title": "Name"
                },
                "Shortname": {
                    "type": "Text",
                    "title": "Shortname"
                },
                "Url": {
                    "type": "Text",
                    "title": "URL"
                }
            }
        },            
<% model.navigation.forEach(function(s){ %>

<%= s.Url %>
<% }); %>

Thanks.

Imran Khan
  • 29
  • 1
  • 9