简体   繁体   中英

Using Express-HandleBars in Node.js

I am getting a template render error when using the # token in my hbs file. I properly installed all of the dependencies but I do not know how to fix this error or why this is happening.

app.get('/h',function(req,res) {

    username =  req.session.username;
    con.query('SELECT symbol FROM watch_list WHERE username =?', [username], function (err, result) {   
         res.render('watchlist2',{result: result});

    });

});
 <table>
    <tbody>
        {{#each result}}
            <tr>
                <td>{{this.symbol}}</td>

            </tr>
        {{/each}}
    </tbody>
</table>

Could it be that this.symbol does not exist?

Check existence before output

<td>{#if this.symbol}}{{this.symbol}}{{/if}}</td>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM