首页 > 解决方案 > 带有灰尘模板的 KrakenJs 循环通过对象错误

问题描述

我应该已经得到了 else 部分,但我得到了错误:购物车的预期结束标签,但它没有找到。在第 21 行第 35 列。我不知道问题出在哪里一切都很好可能是缩进错误请查看代码并建议我。谢谢,还附上了错误的屏幕截图。这是我的灰尘文件:

{>"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}

这是我的控制器

    '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});
    });
 });

我收到此错误:

这是错误屏幕截图

标签: node.jsdust.jskraken.js

解决方案


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

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

推荐阅读