最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Underscorejs洗牌与EJS

运维笔记admin10浏览0评论

Underscorejs洗牌与EJS

Underscorejs洗牌与EJS

使用

是否有可能使用_.shuffle(list)与EJS?

我得到_没有定义。

<script type=".js/1.9.1/underscore-min.js"></script>

<% var breakfastFoods = []  %>
<% var breakfastFoodsInfo = []  %>
<% for (var food of allDBFoods) { %>
<% if (food.breakfast == true ){ %>
<% breakfastFoods.push(food.name) %>
<% breakfastFoodsInfo.push(food.info) %>
<% } %>
<% } %>


<% _.shuffle([breakfastFoods]); %>
回答如下:

我会想象的过程是相似的,但是这是我做我的EJS文件模板使用moment

# routes.js

const moment = require('moment');


app.get('/fixtures', (req, res) => {
  const file = await readFile('./views/partials/fixtures.ejs');
  const fixtureTemplate = ejspile(file, { client: true });
  const html = fixtureTemplate({ moment });
  res.send({ html });
});

在我examples.ejs文件,我可以再使用瞬间像这样

<%=  moment.utc(fixture.kick_off).local().format('HH:mm') %>

希望你可以按照使用underscore相同的过程

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论