nunjucks include问题
发布于 8 年前 作者 DevinXian 7987 次浏览 来自 问答

模板路径配置.../templates目录,目录下有模板a.htmlb.html,我这样用

 //a.html中
 {% include "b.html" %}
//报错,找不到模板 b.html
7 回复

relative include 已经支持了… include "./b.html"

btw use swig / swig-templates instead

前面加上./再试试

@liygheart

Template render error: (unknown path)
	Error: template not found: ./includes/ban-list.html

@magicdawn 我可能哪里做的不对…没理由这个都不支持

在哪个目录下运行的服务器? 路径寻找是基于当前目录/模板目录/模板文件, 我的是这样的. server/server.js views/*.nunj server.js里面直接用的views而不是…/views

可能要用绝对路径,遇到过类似问题,用绝对路径解决了。

回到顶部