[求助]在 Jade 的 extends 那里出错了, 正确的用法应该是什么?
Jade 的 extends
弄了半天不明白,
我出错的时候的目录结构是这样的:
➤➤ tree
.
├── app.coffee
├── html
├── lib
│ ├── content.coffee
│ ├── index.coffee
│ └── source.coffee
├── package.json
├── self
│ ├── coffee
│ │ └── h.coffee
│ ├── css
│ │ └── global.css
│ ├── jade
│ │ ├── layout.jade
│ │ └── page.jade
➤➤ cat self/jade/layout.jade
!!!5
html
head
title #{title}
meta(charset='utf-8')
link(rel='stylesheet',href='/self/css/global.css')
script(src='http://192.168.1.117:8072/doodle.js')
body
#box
#side
#banner
for name in paths
span.seperate /
a.name(href="#{name.url}")= name.text
#index
for item in files
.file
a.filename(href='#{item.url}')= item.text
block content
#body this is a directory
➤➤ cat self/jade/page.jade
extends layout.jade
block content
#body= html
报错是这样的:
➤➤ coffee app.coffee
Error: ./self/jade/layout.jade:1
> 1| !!!5
2| html
3| head
4| title #{title}
ENOENT, no such file or directory 'self/jade/layout.jade.jade'
at Object.fs.openSync (fs.js:338:18)
at Object.fs.readFileSync (fs.js:182:15)
at Object.Parser.parseExtends (/opt/app/page-site/node_modules/jade/lib/parser.js:413:18)
at Object.Parser.parseExpr (/opt/app/page-site/node_modules/jade/lib/parser.js:206:21)
at Object.Parser.parse (/opt/app/page-site/node_modules/jade/lib/parser.js:130:25)
at parse (/opt/app/page-site/node_modules/jade/lib/jade.js:100:62)
at Object.exports.compile (/opt/app/page-site/node_modules/jade/lib/jade.js:163:9)
at Object.<anonymous> (/opt/app/page-site/lib/content.coffee:32:20)
at Object.<anonymous> (/opt/app/page-site/lib/content.coffee:95:4)
at Module._compile (module.js:449:26)
代码在 lib/
下面的文件夹里面:
page.path = '../self/jade/page.jade'
page.path = path.join __dirname, page.path
page.tmpl = fs.readFileSync page.path, 'utf8'
page.html = jade.compile page.tmpl,
pretty: yes, filename: './self/jade/layout.jade'
我试过去掉后缀, 但那又提示文件找不到…
Error: ENOENT, no such file or directory './self/jade/layout'
7 回复
旁观