node.js - 带有灰尘模板的 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});
});
});
我收到此错误:
解决方案
数学助手应该关闭。例如:
{@math key="{.price}" method="multiply" operand ="{.qty}" /}
推荐阅读
- java - 为什么移位运算符>>中负数的结果与正常除法不同?
- scala - Spark Scala 累积唯一计数(按日期)
- python - Python Django Webapp 在智能手机中没有响应
- sublimetext3 - macOS Sublime Text 3:如何禁用一个窗口/选项卡式窗口?
- excel - 在 Excel 中,我有两列,我想根据右列中的文本值突出显示
- sql - 优化动态排序 SQL 查询
- assembly - 引导扇区仅在 QEMU 中有效
- c++ - 我可以存储一组 iostream 而不在堆上手动分配它们吗?
- kubernetes - bookinfo 示例应用程序的 Istio mTLS 问题
- python - 在 Python 中对网格进行矢量化计算