Node.js EJS:<;%vs<;%---&燃气轮机;什么';有什么区别

Node.js EJS:<;%vs<;%---&燃气轮机;什么';有什么区别,node.js,express,ejs,Node.js,Express,Ejs,总结了之间的差异,谢谢@antonku。对您所说的做了一些研究,并在include JS函数的两种不同的include-->调用中,而传统方法是一个预处理器指令,它解释了行为上的差异。根据:-您很可能不应该在include指令上使用-%>结束标记,因为它会修剪包含文件后的空白。@MohitBajaj感谢您分享更多信息 <%# Include header %> <% include partials/header %> //Using <% <h1>T

总结了
之间的差异,谢谢@antonku。对您所说的做了一些研究,并在include JS函数的两种不同的include-->
调用中,而传统方法是一个预处理器指令,它解释了行为上的差异。根据:-您很可能不应该在include指令上使用-%>结束标记,因为它会修剪包含文件后的空白。@MohitBajaj感谢您分享更多信息
<%# Include header %>
<% include partials/header %> //Using <%

<h1>This is the home page</h1>
<p>Some content goes here</p>

<%# Include footer %>
<%- include partials/footer %> //using <%-
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="/app.css">
    <title>Demo App</title>
</head>
<body>
const template = '<%- user %>';
ejs.render(template, { user: 'Alice' }); // renders "Alice"
const template2 = '<% users.map(user => { %> <%- user -%> <% }) %>';
ejs.render(template, { users: ['Alice', 'Bob'] }); // renders "Alice  Bob"
<% include("partials/header") %>
<% include partials/header %>