Got a solution from the maintainer MustacheJS,
JSBin Work
I can use the product-list template because both product-list and recurisve-list are similar: $('body').html(Mustache.render(productList.html(), data, {recurse: productList.html()}));
If you do, you will get maximum call stack size exceeded , which you probably would not have expected. This is because by structuring your data and templates the way you did, you created infinite recursion. In products with a tail (for example, Nexus 4, Nexus 6, iPod, etc.), the Template will look for the product property, and not find it. This way, it will update the context stack and check each level until it finds something with the product property. You can stop this by making sure that leaf products have a product property with a value such as false, null or [] .
New data:
var data = { product: [{ productName: "Category1", product: [{ productName: "Windows", product: null }, { productName: "Windows Mobile", product: null }] }, { productName: "Category2", product: [{ productName: "SubCategory 1", product: [{ productName: "Nexus 4", product: null }, { productName: "Nexus 6", product: null }] }, { productName: "SubCategory 2", product: [{ productName: "ipod", product: null }, { productName: "iphone", product: null }] }] }] };
source share