Hi Lance!

The problem is not the JS Use API but the way the JS Iterator is used. One
should do:

for (var [key, res] in Iterator(children)) {
        returnObj.content += res.name;
}

Also, Robert is right, you should strive to keep your business logic (use
objects) as light as possible do the iterating and rendering in the HTL
script, if possible.

Best,
Vlad

On Wed, Jan 11, 2017 at 1:00 PM, Robert Munteanu <[email protected]> wrote:

> Hi,
>
> On Tue, 2017-01-10 at 18:29 -0700, lancedolan wrote:
> > All I want to do is print out a resource's children resources.
>
> Using the HTL repl [1] I narrowed down the following way of listing
> child resources:
>
> template.html
> -------------
>
> <html>
> <head>
>     <title>${properties.jcr:title}</title>
>     <meta charset="utf-8">
> </head>
> <body data-sly-use.obj="logic.js">
>
>     <p>My siblings are:
>         <ul data-sly-list.child="${obj.siblings}">
>             <li>${child.name}</li>
>         </ul>
>     </p>
>
> </body>
> </html>
>
> logic.js
> --------
>
> use(function () {
>     return {
>         siblings: resource.getParent().getChildren()
>     };
> });
>
> I don't know enough about the HTL Javascript Use API to see what is
> wrong in your particular example unfortunately.
>
> Robert
>
>
> [1]: http://localhost:8080/htl/repl.html
>

Reply via email to