mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.7k stars 841 forks source link

Not able to access array of object of array of object and so on in ejs with script #662

Closed tirathsharma098 closed 2 years ago

tirathsharma098 commented 2 years ago

here countryData is an array of object of object. [ {name: 'countryname' , states : [{name : 'stateName'}, .............]}, .......... ] I am trying to append all states name for respective selected country when user select an country and taking the sending the countryData while rendering to template. But, I am not able to use variable name that i got while rendering interchangebly which is necessary. My ejs script file, image partial include image select Input image I am able to append country name successfully query is just for states name. Because not able to access array of object of array of object and so on in ejs with script.

mde commented 2 years ago

It would appear that part of the problem is that you're mixing client- and server-side execution with your EJS. I can't tell from your first code example if you're trying to create client-side-executable JavaScript with your server-rendering, or build a client-renderable template with your client-side execution (or if you're just mixing things together, and hoping for the best).

I am going to close this issue because it is almost certainly not a problem with the EJS library itself. And you don't provide a minimal (EJS-only) failing example, there's very little I can do to help. This is a problem in your application code somewhere. If you can give me that minimal, EJS-only example, feel free to reopen.