H
H
hsuper2017-12-28 18:18:03
Handlebars
hsuper, 2017-12-28 18:18:03

Handlebars help?

I'm making my first blog, but I ran into a problem,
Sends posts to the main page

app.get('/', (req,res) => {
    PostModel.find((err,doc) => {   if(err) throw err;
         res.render('index', {posts : doc}); console.log(doc); });
 
});

index.hbs
<h2>Добро пожаловать на мой блог</h2>
    <div class="posts">
        {{#each posts}}

        {{#each this}}

        <h4>{{this.title}}</h4>
        <p>{{this._id}}</p>
         

        {{/each}}
        
        {{/each}}
    </div>

Outputs:
5a450af8e2125254716239.png
MongoDb Composition:
5a450ac1b9646082059869.png
Why are _id output 2 times?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2017-12-28
@hsuper

What is the {{#each this}}purpose of this template?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question