0
I’m passing data to the handlebars through the express so:
res.render('user/apps/todos', { todos: JSON.stringify(todos) });`
And so I get on the page:
{{ todos }}
Now, if todos
for:
[{"title":"My first todo","body":"My first todo's body"},{"title":"My first todo 3","body":"My first todo's body 3"},{"title":"SAD","body":"INSANE AMOUNTS OF SADNESS\n3"}]
The handlebars convert me to:
[{"title":"My first todo","body":"My first todo's body"},{"title":"My first todo 3","body":"My first todo's body 3"},{"title":"SAD","body":"INSANE AMOUNTS OF SADNESS\n3"}]
How to prevent handlebars from doing this operation?
Try using it this way: res.render('user/apps/all', { all: all });
– cpurificacao
Forehead only with
res.render('user/apps/todos', {todos});
, you don’t need theJSON.stringify
– Sergio
@Apolomaster Precise, otherwise I get [Object Object],[Object Object],[Object Object]
– Simple coder
If you put
{{ todos }}
appears[object Object]
... makes sense. But inside that everyone wants to show only parts right? You can give an example of the HTML you expect to get?– Sergio
@Sergio I wanted to get what I provided in the render function, which is the all array
– Simple coder
Yes, but you want to display the "raw" array or iterate the data and create HTML with it?
– Sergio