ejs

愿一切安好!

妖精的绣舞 提交于 2020-04-06 11:06:59
Hexo 静态博客 完整支持特殊日子黑白悼念,愿生者坚强,逝者安息! 方法 1 静态方法,直接在模板文件中添加 CSS 样式: <style> html { FILTER: gray; -webkit-filter: grayscale(100%); } </style> 方法 2 动态方法,可在 _config.yml 中进行配置多个日期: grieve: - '5-12' - '9-18' - '2020-4-4' 页面模板如 footer.ejs 中: <script type="text/javascript" src="/js/grieve.js"></script> <% if (config.grieve) { %> <script> grieveIfNeed('<%= config.grieve %>') </script> <% } %> 创建 JS 文件 grieve.js 放到 js 文件夹下: grieveIfNeed = function (dateList) { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var dateArray = dateList.split(',')

[转]express常用中间件

孤者浪人 提交于 2020-04-05 18:52:10
express常用中间件 整理一下工作中经常使用到的Express中间件 config-lite: 读取配置文件 不同环境下配置文件使用 - Node实战 config-lite express-session: session 中间件 nodejs 实践:express 最佳实践(四) express-session 解析 express-session Express + Session 实现登录验证 connect-mongo: 将 session 持久化存储于 mongodb,结合 express-session 使用 connect-mongo模块 github mongolass: mongodb 驱动 mongolass connect-flash: 页面通知提示的中间件,基于 session 实现 connect-flash 用法详解 body-parser是一个HTTP请求体解析中间件 Express使用进阶:cookie-parser中间件实现深入剖析 Express 中间件----body-parser cookie-parser 用来获取和删除 cookie的中间件 Express使用进阶:cookie-parser中间件实现深入剖析 node会话管理——cookie-parser winston、express-winston 日志中间件 日志中间件

How to reference layout images in express.js so that they can be found from nested directories?

人盡茶涼 提交于 2020-03-26 07:20:13
问题 I've got an express.js app currently using ejs (using jade for newer projects) and I'm trying to solve a problem in a clean and appropriate manner. I've got a layout.ejs file with my header and footer in it. Most of my site so far has been one layer deep http://innovationbound.com/about or /services or /amy and so on.... I'm beginning to created online courses at http://innovationbound.com/courses/course-name and the issue I'm having is that these course pages can't reference the images the

How to sort data in JQuery

允我心安 提交于 2020-03-25 19:13:22
问题 I'm working on a slider which is showing data from the backend. Using the "push" function it is showing slides in the slider according to date. But I need it to show these slides according to date & status. Firstly show incomplete status (btn-danger), after it show pending status (btn-success), and then completed status (btn-warning). screenshot of code https://ibb.co/5KJpdrh full code: paste.ofcode.org/hmKSwTvaWrjTj3A6rWh464 code: function handleSubmit(command) { if(command === 'meeting') {

ejs - “Unexpected identifier” when using include in for loop

自古美人都是妖i 提交于 2020-03-20 06:54:04
问题 I'm using <% include components/aside.ejs %> or <% include components/head.ejs %> somewhere in my code without any problem. But when I use include in a for loop like this <% for (var i = 0; i < 20; i++) { include components/head.ejs; } %> , I get Unexpected identifier in [file path] while compiling ejs . Is there any obvious mistake that I'm not noticing? 回答1: To fix a breaking change, as of EJS 3.x, the syntax for an include has gone from <%- include components/head.ejs %> to <%- include(

ejs模板引擎

梦想的初衷 提交于 2020-03-04 11:46:40
ejs模板引擎 什么是ejs模板引擎 如何使用ejs 文档结构 示例 因数计算程序 创建文件 静态页面创建 服务搭建 ejs文件 请求方式 什么是ejs模板引擎 “E” 代表什么?可以表示 “可嵌入(Embedded)”,也可以是“高效(Effective)”、“优雅(Elegant)”或者是“简单(Easy)”。 EJS 是一套简单的模板语言,帮你利用普通的 JavaScript 代码生成 HTML 页面。 ejs将页面在后端渲染完成后再返回给前端。 如何使用ejs 首先需要安装ejs npm i ejs 然后在项目内引入 const ejs = require ( "ejs" ) ; const app = require ( 'express' ) ; //设置视图引擎 app . set ( 'view engine' , 'ejs' ) ; app.set(‘view engine’,‘ejs’);这行代码必须要写。 文档结构 使用ejs后会自动寻找views文件夹下的ejs文件 demo public css index.html demo.css views demo.ejs app.js 使用ejs则views文件夹必须存在, 示例 我们通过一个例子来对ejs模板引擎有一个更深刻的理解 因数计算程序 我们的目标是写出一个因数计算程序,可以计算一个数的因数

SyntaxError: missing ) after argument list in while compiling ejs

妖精的绣舞 提交于 2020-02-22 07:13:53
问题 I am getting the error: missing ) after argument list while compiling ejs. I tried many times, but I can't find the problem. Here's the ejs that causes errors. What is the problem with this code? <%- include('../_layouts/adminheader') %> <h2 class='page-title'>Products</h2> <br> <a href="/admin/products/add-product" class="btn btn-primary">Add a new product</a> <br><br> <% if (count > 0) { %> <table class="table table-striped"> <thead> <tr class="home"> <th>Product</th> <th>Price</th> <th

SyntaxError: missing ) after argument list in while compiling ejs

此生再无相见时 提交于 2020-02-22 07:06:44
问题 I am getting the error: missing ) after argument list while compiling ejs. I tried many times, but I can't find the problem. Here's the ejs that causes errors. What is the problem with this code? <%- include('../_layouts/adminheader') %> <h2 class='page-title'>Products</h2> <br> <a href="/admin/products/add-product" class="btn btn-primary">Add a new product</a> <br><br> <% if (count > 0) { %> <table class="table table-striped"> <thead> <tr class="home"> <th>Product</th> <th>Price</th> <th

SyntaxError: missing ) after argument list in while compiling ejs

流过昼夜 提交于 2020-02-22 07:05:48
问题 I am getting the error: missing ) after argument list while compiling ejs. I tried many times, but I can't find the problem. Here's the ejs that causes errors. What is the problem with this code? <%- include('../_layouts/adminheader') %> <h2 class='page-title'>Products</h2> <br> <a href="/admin/products/add-product" class="btn btn-primary">Add a new product</a> <br><br> <% if (count > 0) { %> <table class="table table-striped"> <thead> <tr class="home"> <th>Product</th> <th>Price</th> <th

Calling stored procedure from node js

不问归期 提交于 2020-02-21 06:33:59
问题 I am using express and I am trying to call LoginMember stored procedure from Azure portal. This is my form from, taken from ejs: <form method="post" action="/available-copies"> <input type="text" placeholder="SSN" name="userssn"> <input type="password" placeholder="Password" name="userpassword"> <input type="submit" value="Login"> </form> This is my post request router.post('/available-copies', function (req, res) { var ssn = req.body.userssn; var password = req.body.userpassword; sql.connect