node.js - KrakenJs 与 Dust 模板循环遍历对象错误

标签 node.js dust.js kraken.js

I should Have got the else part but I am getting the error: Expected end tag for cart.items but it was not found. At line : 21, column : 35. I don't know where is the problem everything is fine may be indentation error please look out the code and suggest me. thanks there is also attached screen shot of the error. this is my dust file:

{>"layouts/master" /}
    {<body}
     <div class="row">
        <div class="container">
            <h2>Your Cart</h2>
            {?cart.items}
                <table>
                    <thead>
                        <tr>
                            <th>Item</th>
                            <th>Quantity</th>
                            <th>Total</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        {#cart.items}
                            <tr>
                                <td><a href="books/details/{._id}">{title}</a></td>
                                <td>{.qty}</td>
                                <td> ${@math key="{.price}" method="multiply" operand ="{.qty}"}</td>
                                <td><a href="#" class="btn btn-danger">Remove</a></td>
                            </tr>
                        {/cart.items}
                    </tbody>
                </table>
                <div class="row">
                        <div class="col-sm-6">
                           <h4> Total <strong>${cart.total}</strong></h4>
                        </div>

                        <div class="col-sm-6">

                       </div>
                </div>
                {:else}
                    <p>There is no Items in your cart</p>
            {/cart.items}
        </div>
     </div>

    {/body}

this is my controller

    'use strict';

var Book = require('../models/bookModel');
var Category = require('../models/categoryModel');

module.exports = function (router) {
    router.get('/', function (req, res) {
        var cart = req.session.cart;
        var displayCart = {
            items: [], total: 0
        };

        var total = 0;
        //get total

        for(var item in cart){
            displayCart.items.push(cart[item]);
            total += (cart[item].qty * cart[item].price);
        }
        displayCart.total = total;

        res.render('cart/index', {cart: displayCart});
    });
 });

I am Getting this error:

this is error screen shot

最佳答案

数学助手应该关闭。例如:

{@math key="{.price}" method="multiply" operand ="{.qty}" /}

关于node.js - KrakenJs 与 Dust 模板循环遍历对象错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51532655/

相关文章:

javascript - Express Generator 和 KrakenJS 有什么区别?

node.js - 海妖JS : mogran deprecated undefined format: specify a format

node.js - 从 package.json 运行两个脚本

node.js - 使用 Node.JS zlib 模块解压缩没有 header 的 gzip 数据

javascript - 检查占位符文本中是否存在 null 或空值

javascript - dust.js 过滤 json 结果

node.js - 如何使用 Kraken.js 为 Bookshelf 配置 Knex

javascript - 如何使用 n1ql 查询更新 couchbase 中的数组

javascript - MongoDB $regex 运算符不使用 mongoc 的 NodeJS

javascript - 当我直接通过ID访问它时,jquery on click不会触发