[英]Unexpected "/" in <filepath> while compiling ejs
我已經在路徑views/partials/ejspartial.ejs
下設置了一個 EJS 部分,我試圖在路徑views/ejsfile.ejs
的 ejs 文件中訪問views/ejsfile.ejs
。 這是相同的視圖目錄。
在ejsfile.ejs
,我添加了以下代碼行: <% include ./partials/ejspartial %>
當我加載 ejsfile 頁面時,出現以下錯誤:
SyntaxError: Unexpected token '/' in <path>/views/ejsfile while compiling ejs
我嘗試在<%-
標記中交換並從include
語句中刪除./
,但發生了同樣的錯誤。
我懷疑這是因為您使用的是舊版 EJS 的語法。
我注意到文檔說:“注意:仍然支持包含預處理器指令( <% include user/show %>
)。”
但是,EJS 存儲庫的所有者在這里另有說明: https : //github.com/tj/ejs/issues/220
我會嘗試新語法<%- include('partials/ejspartial') %>
,看看是否能解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.