# Problems rendering nested divs with handlebars.js

**URL:** <https://forum.freecodecamp.org/t/problems-rendering-nested-divs-with-handlebars-js/251178>\
**Category:** General\
**Created:** [January 13, 2019, 5:00am UTC](https://forum.freecodecamp.org/t/problems-rendering-nested-divs-with-handlebars-js/251178 "2019-01-13T05:00:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nastyhobbitses](https://avatars.discourse-cdn.com/v4/letter/n/3ab097/32.png) [@nastyhobbitses](https://forum.freecodecamp.org/u/nastyhobbitses)\
**Post date:** [January 13, 2019, 5:00am UTC](https://forum.freecodecamp.org/t/problems-rendering-nested-divs-with-handlebars-js/251178/1 "2019-01-13T05:00:53Z")

</div>

Newbie here so please bear with me. I’m trying to render nested divs with handlebars but I’ve come across trouble writing the code for it. This is what I’ve been testing on the console.

```auto
var handlebarsTemplate= "<div id='{{comment.id}}'>{{comment.value}}{{{some comment}}}</div>"

var post = {
comment:{
id:"123", value: "hello handlebars windows page",
newArray: [{id:"321", value: "hey", newArray:[{id:"444", value:"hullo", newArray:[]}]}]
}
}

Handlebars.registerHelper("some", function iter(obj){
    if(obj.newArray.length!==0){
        for(var i=0;i<obj.newArray.length;i++){
            var psot = document.createElement("div");
            psot.id = obj.newArray[i].id
            psot.innerHTML = obj.newArray[i].value;
			var theIdd = obj.id
            var dives = document.getElementById(theIdd);
                    dives.appendChild(psot);
            iter(obj.newArray[i])
        }
    }
})

Handlebars.compile(handlebarsTemplate)(post)

//whenever I run it all I get is whats below, but I want it to nest the other values inside this div.

"<div id='123'>hello handlebars windows page</div>"

```

Where am I going wrong please?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:06pm UTC](https://forum.freecodecamp.org/t/problems-rendering-nested-divs-with-handlebars-js/251178/2 "2021-01-17T20:06:27Z")

</div>

Closed on January 17, 2021, 8:06pm UTC


